You can use the Session.createQueue(String) method or Session.createTopic(String) method instead of using JNDI lookup to create a JMS Queue or JMS Topic with the default messaging provider.
Queue q = mySession.createQueue("Q1");
creates
a JMS Queue instance that can be used to reference the existing destination
Q1.With the default messaging provider, the existing destination exists as a queue or topic space on the bus to which the session is connected.
The Session.createQueue(String) method is used to create a JMS Queue object representing an existing destination. This provides an alternative, but less manageable, approach to obtaining administratively-defined JMS Queue objects by JNDI lookup.
Queue q = mySession.createQueue("Q1");
Queue q = mySession.createQueue("queue://Q1");
Queue q = mySession.createQueue("queue://Q2?busName=otherBus");
When
sending messages to WebSphere® MQ,
the queue name must be followed by an at sign (@) and the name of
the queue manager on which the queue is located, for example : Queue q = mySession.createQueue("queue://Q2@qmgr?busName=otherBus");
Queue q = mySession.createQueue("queue://Q2?busName=otherBus&deliveryMode=
Application&readAhead=AsConnection&priority=6");
The Session.createTopic(String) method is used to create a JMS Topic object representing an existing destination. (Note that for topics it is the topic space rather than the topic that exists.) This provides an alternative, but less manageable, approach to obtaining administratively-defined JMS Topic objects by JNDI lookup.
Topic t = mySession.createTopic("cats");
Topic t = mySession.createTopic("kennelTopicSpace:dogs");
Topic t = mySession.createTopic("topic://cats");
Topic t = mySession.createTopic("topic://dogs?topicSpace=kennelTopicSpace");
As for queues, multiple name value pairs are separated by an ampersand &.
WebSphere Application Server Version 5.1 applications can use createQueue and createTopic methods to create JMS Queue and Topic objects with the Version 5 embedded messaging provider (the Version 5.1 JMS messaging provider). To assist you in migrating these applications, the default messaging provider (the service integration bus) supports a large subset of valid MA88-specific string parameters to the createQueue and createTopic methods.
queue://qm/queue
To specify the default queue manager, the queue manager name is omitted; for example: queue:///queue (note the three forward slash characters, ///). Because the interpretation of the default queue manager is logically consistent with the concept of a queue on the current bus, the bus tolerates the presence of three forward slash characters following the queue: prefix. This allows MA88 queue URIs with a default queue manager to be used by the bus without change.
MA88 name | Service integration bus name | Notes |
---|---|---|
expiry | timeToLive | |
persistence | deliveryMode | 1 = NonPersistent |
A topic used for consuming messages can include wildcards. The wildcard syntax used in MA88 differs from the XPath syntax used in the bus, so if an MA88 URI contains wildcards the bus attempts to convert them to XPath equivalents. The conversion performed depends on the presence of the brokerVersion property in the MA88 URI. The WebSphere Application Server Version 5.1 default messaging provider required any URI specifying a topic wildcard to include brokerVersion=1 in the name value pairs. The bus therefore uses brokerVersion=1 as the trigger to undertake MQSI to XPath wildcard conversion.
All parts of the string parameter for createQueue and createTopic are case sensitive.
If a URI contains multiple occurrences of a given property with conflicting values, it is not specified which value is used.
If a URI contains both a property and the MA88 equivalent of that property with conflicting values, it is not specified which value is used.
Any name value pairs for which the property name is not recognized are ignored without any error reporting.
createTopic("myTop\\:ic") creates a topic with the name "myTop:ic"
createTopic("topic://my\\?Topi\\\\c") creates a topic with the name "my?Topi\c"
createQueue("queue://q1?busName=silly\\&bus") creates a queue with bus name "silly&bus"