When we are trying publish JMS using JSR223 sampler in JMeter for a queue/topic to run a performance test we are getting the following error.
javax.script.ScriptException: javax.jms.InvalidDestinationException: Not allowed to create destination.
When we checked with JMS team all the queue details are correct. All the respective jar files are placed under JMeter's lib folder. We are able to publish the message from Eclipse with same queue details but facing issue when testing from JMeter.
Editing the question -- below is the sample groovy code used in the JSR223 sampler.
Unfortunately, we are not able to use the code from Eclipse as it has lot of maven dependencies.
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.naming.*;
// message submission initial phase
String providerURL = "ldap://sample.com";
String CFDestination = "connection factory details"; //connection factory
String destination = "Topic name"; // Queue or Topic
String CONTEXT_FACTORY = "Client specific TibcoInitialContext";
String login = "User";
String passwd = "pwd";
String file = null;
int maxLimit = -1;
int counter = 0;
Properties lookup = new Properties();
lookup.setProperty( Context.INITIAL_CONTEXT_FACTORY, CONTEXT_FACTORY );
lookup.setProperty( Context.PROVIDER_URL, providerURL );
InitialContext context = new InitialContext(lookup);
ConnectionFactory factory = (ConnectionFactory) context.lookup( "fxClientUID=" + CFDestination );
//ConnectionFactory factory = (ConnectionFactory) context.lookup("fxClientDestinationUID=" + CFDestination);
Connection connection = factory.createConnection(login, passwd);
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE );
MessageProducer producer = session.createProducer(session.createTopic(destination));
CFDestination.setPubSubDomain(true);
// end of initial phase
// message submission
long iTrackingNumber;
String DS_TrackingNbr = "123456789";
iTrackingNumber= iTrackingNumber.valueOf(DS_TrackingNbr);
String sTrackingNumber = "";
//for ( int i =0 ; i<30000; i++)
for ( int i =0 ; i<1; i++)
{
iTrackingNumber = iTrackingNumber +1;
sTrackingNumber = String.valueOf(iTrackingNumber);
String strPart1 = """Message to publish""";
String messageString = strPart1;//+sTrackingNumber+strPart2;
Message message = session.createTextMessage(messageString);
//message.setStringProperty("TriggerEventType","CE");
message.setStringProperty("TriggerEventType", "CE");
message.setStringProperty("SourceType", "ITIH");
message.setStringProperty("GEOCODE", "REU");
producer.send(message);
sleep(1);
}
// end of message submission
// post submission phase
connection.close();
session.close();
context.close();
// end of post submission
We cannot help you without seeing your JMS test element configuration and your Java code "from Eclipse"
Looking into the error details it looks like "queue and connection details" are not "the same".
If you can successfully post a message "from Eclipse" you can use the same code in JSR223 Sampler, make sure to choose Groovy as the language.
You might also want to check out Building a JMS Point-to-Point Test Plan guide.