Mais conteúdo relacionado
Semelhante a What's new in JMS 2.0 - OTN Bangalore 2013 (20)
Mais de Jagadish Prasath (7)
What's new in JMS 2.0 - OTN Bangalore 2013
- 2. Easier Messaging
with JMS 2.0
Jagadish Ramu
Application Server Group
Oracle
Copyright © 2013, Oracle and/or its affiliates. 2 All rights reserved.
- 3. The following is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2013, Oracle and/or its affiliates. 3 All rights reserved.
- 4. Java Message Service (JMS)
l A Java API for sending and receiving messages
l Many competing implementations
l Two distinct API variants
l Java SE applications
l Java EE applications – adds additional features
l JTA (XA) transactions
l Replaces async MessageListener with MDBs,
l Injection of connection factories and destinations using
@Resource
l (New!) Injection and management of JMSContext objects
Copyright © 2013, Oracle and/or its affiliates. 4 All rights reserved.
- 5. What JMS is and isn't
A standard API
Not a messaging system in itself
Not a wire protocol
Defines Java API only
Doesn't define API for non-Java clients (e.g. C++, HTTP) - but many
implementations do
An application API
Not (currently) an admin, management or monitoring API
Copyright © 2013, Oracle and/or its affiliates. 5 All rights reserved.
- 6. JMS 2.0
JMS 1.1 (2002)
Dozens of implementations, both standalone and as part of a full
Java EE provider
JMS 2.0 (2013)
Launched in 2011 as JSR 343
Released in 2013 with Java EE 7
Available in Open Message Queue 5.0 (standalone JMS provider)
and in GlassFish 4.0 (full Java EE provider)
Other implementations announced or in progress
Copyright © 2013, Oracle and/or its affiliates. 6 All rights reserved.
- 7. What's new in JMS 2.0
l Simpler and easier to use
l New messaging features
l Better Java EE integration
l Define differences between JMS in SE and EE more
clearly
l Simpler resource configuration
l Standardized configuration of JMS MDBs
l Minor corrections and clarifications
Copyright © 2013, Oracle and/or its affiliates. 7 All rights reserved.
- 8. JMS 2.0
Simpler and easier to use
Copyright © 2013, Oracle and/or its affiliates. 8 All rights reserved.
- 9. JMS API simplifications
Twin-track strategy
l Make minor simplifications to existing standard API where it won't
break compatibility
l Define new simplified API requiring fewer objects
JMSContext, JMSProducer, JMSConsumer
In Java EE, allow JMSContext to be injected and managed by the
container
Copyright © 2013, Oracle and/or its affiliates. 9 All rights reserved.
- 10. Why did JMS 1.1
need simplifying?
Copyright © 2013, Oracle and/or its affiliates. 10 All rights reserved.
- 11. JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 11 All rights reserved.
13 lines of
code just
to send a
message
- 12. JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 12 All rights reserved.
must create
several
intermediate
objects
- 13. JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 13 All rights reserved.
redundant
and
misleading
arguments
- 14. JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 14 All rights reserved.
must
close
resources
after use!
- 15. JMS 1.1: Sending a message
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessage(String payload) {
try {
Connection connection = connectionFactory.createConnection();
try {
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer messageProducer = session.createProducer(demoQueue);
TextMessage textMessage = session.createTextMessage(payload);
messageProducer.send(textMessage);
} finally {
connection.close();
}
} catch (JMSException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 15 All rights reserved.
all
methods
throw
checked
exceptions
- 16. Minor simplifications to the
existing standard API
Copyright © 2013, Oracle and/or its affiliates. 16 All rights reserved.
- 17. Minor simplifications to the standard API
Simpler API to create a Session
Methods on javax.jms.Connection to create a Session:
l JMS 1.1 method remains
connection.createSession(transacted,
acknowledgeMode)
l New method combines two parameters into one:
connection.createSession(sessionMode)
l New method mainly for Java EE
connection.createSession()
Session.SESSION_TRANSACTED Session.AUTO_ACKNOWLEDGE,
Session.CLIENT_ACKNOWLEDGE Session.DUPS_OK_ACKNOWLEDGE
Copyright © 2013, Oracle and/or its affiliates. 17 All rights reserved.
- 18. Minor simplifications to the standard API
Simpler API to close JMS objects
l Make JMS objects implement java.jang.AutoCloseable
Connection
Session
MessageProducer
MessageConsumer
QueueBrowser
l Requires Java SE 7
Copyright © 2013, Oracle and/or its affiliates. 18 All rights reserved.
- 19. Minor simplifications to the standard JMS API
Simpler API to close JMS objects
@Resource(lookup = "jms/connFactory")
ConnectionFactory cf;
@Resource(lookup="jms/inboundQueue")
Destination dest;
Create closeable
resources in a
try-with-resources
Make JMS objects implement java.jang.AutoCloseable
Connection, Session, MessageProducer,
MessageConsumer, QueueBrowser
public void sendMessage (String payload) throws JMSException {
try ( Connection conn = connectionFactory.createConnection();
Session session = conn.createSession();
MessageProducer producer = session.createProducer(dest);
){
Message mess = sess.createTextMessage(payload);
producer.send(mess);
} catch(JMSException e){
// exception handling
}
}
Copyright © 2013, Oracle and/or its affiliates. 19 All rights reserved.
block
close() is called
automatically
at end of block
- 21. Completely new simplified API
Introducing JMSContext and JMSProducer
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessageNew(String payload) {
try (JMSContext context = connectionFactory.createContext();){
context.createProducer().send(demoQueue, payload);
} catch (JMSRuntimeException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 21 All rights reserved.
13 lines
reduced
to 5
- 22. Completely new simplified API
Introducing JMSContext and JMSProducer
@Resource(lookup = "java:global/jms/demoConnectionFactory")
ConnectionFactory connectionFactory;
@Resource(lookup = "java:global/jms/demoQueue")
Queue demoQueue;
public void sendMessageNew(String payload) {
try (JMSContext context = connectionFactory.createContext();){
context.createProducer().send(demoQueue, payload);
} catch (JMSRuntimeException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
}
Copyright © 2013, Oracle and/or its affiliates. 22 All rights reserved.
JMSContext
combines
Connection
and Session
Payload
can be
sent
directly
- 23. JMSContext (1/2)
l A new object which encapsulates a Connection, a Session and an
anonymous MessageProducer
l Created from a ConnectionFactory
JMSContext context = connectionFactory.createContext(sessionMode);
l Call close() after use, or create in a try-with-resources block
l Can also be injected (into a Java EE web or EJB application)
Copyright © 2013, Oracle and/or its affiliates. 23 All rights reserved.
- 24. JMSContext (2/2)
l Can also create from an existing JMSContext
(to reuse its connection – Java SE only)
JMSContext context2 = context1.createContext(sessionMode);
l Used to create JMSProducer objects for sending messages
l Used to create JMSConsumer objects for receiving messages
l Methods on JMSContext, JMSProducer and JMSConsumer throw only
unchecked exceptions
Copyright © 2013, Oracle and/or its affiliates. 24 All rights reserved.
- 25. JMSProducer
Messages are sent by creating a JMSProducer object
Does not encapsulate a MessageProducer so is lightweight
Supports method chaining for a fluid style
JMS 1.1
MessageProducer producer = session.createProducer();
producer.send(destination,message);
JMS 2.0
JMSProducer producer = context.createProducer();
producer.send(destination,message);
Copyright © 2013, Oracle and/or its affiliates. 25 All rights reserved.
- 26. JMSProducer
Setting message delivery options using method chaining
JMS 1.1
MessageProducer producer = session.createProducer();
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.setPriority(1);
producer.setTimeToLive(1000);
producer.send(destination,message);
JMS 2.0
context.createProducer().setDeliveryMode(DeliveryMode.NON_PERSISTENT).
setPriority(1).setTimeToLive(1000).send(destination,message);
Copyright © 2013, Oracle and/or its affiliates. 26 All rights reserved.
- 27. JMSProducer
Setting message properties and headers
JMS 1.1 (need to set on the message)
MessageProducer producer = session.createProducer();
TextMessage textMessage = session.createTextMessage("Hello);
textMessage.setStringProperty("foo","bar");
producer.send(destination,message);
JMS 2.0 (can also set on the JMSProducer)
context.createProducer().setProperty("foo","bar").send(destination,"Hello");
Copyright © 2013, Oracle and/or its affiliates. 27 All rights reserved.
- 28. JMSProducer
Sending message bodies directly
Methods on JMSProducer to send a Message
send(Destination dest, Message message)
No need to create a Message
send(Destination dest, Map<String,Object> payload)
send(Destination dest, Serializable payload)
send(Destination dest, String payload)
send(Destination dest, byte[] payload)
Use methods on JMSProducer to set delivery options,
message headers and message properties
Copyright © 2013, Oracle and/or its affiliates. 28 All rights reserved.
- 29. JMSConsumer
Messages are consumed by creating a JMSConsumer object
Encapsulates a MessageConsumer
Similar functionality and API to MessageConsumer
Synchronous
JMSConsumer consumer = context.createConsumer(destination);
Message message = consumer.receive(1000);
Asynchronous
JMSConsumer consumer = context.createConsumer(destination);
consumer.setMessageListener(messageListener);
Connection is automatically started (configurable)
Copyright © 2013, Oracle and/or its affiliates. 29 All rights reserved.
- 30. JMSConsumer
Receiving message bodies directly
When consuming messages synchronously
Methods on JMSConsumer that return a Message
Message receive();
Message receive(long timeout);
Message receiveNoWait();
Methods on JMSConsumer that return message body directly
<T> T receiveBody(Class<T> c);
<T> T receiveBody(Class<T> c, long timeout);
<T> T receiveBodyNoWait(Class<T> c);
Copyright © 2013, Oracle and/or its affiliates. 30 All rights reserved.
- 31. JMSConsumer
Receiving message bodies directly
public String receiveMessage() throws NamingException {
InitialContext initialContext = getInitialContext();
ConnectionFactory connectionFactory =
(ConnectionFactory) initialContext.lookup("jms/connectionFactory");
Queue inboundQueue = (Queue)initialContext.lookup("jms/inboundQueue");
try (JMSContext context = connectionFactory.createContext();) {
JMSConsumer consumer = context.createConsumer(inboundQueue);
return consumer.receiveBody(String.class);
}
}
Copyright © 2013, Oracle and/or its affiliates. 31 All rights reserved.
- 32. Extracting the body from a message
In both the standard and simplified APIs
Old way
Message message = consumer.receive(1000);
TextMessage textMessage = (TextMessage) message;
String body = textMessage.getText();
New way
Message message = consumer.receive(1000);
String body = message.getBody(String.class);
Copyright © 2013, Oracle and/or its affiliates. 32 All rights reserved.
- 33. Injection of JMSContext objects
into a Java EE web or EJB container
@Inject
@JMSConnectionFactory("jms/connectionFactory")
private JMSContext context;
@Resource(mappedName = "jms/inboundQueue")
private Queue inboundQueue;
public void sendMessage (String payload) {
context.createProducer().send(inboundQueue, payload);
}
Copyright © 2013, Oracle and/or its affiliates. 33 All rights reserved.
- 34. Injection of JMSContext objects
into a Java EE web or EJB container
Connection factory will default to platform default JMS
@Inject private JMSContext context;
Specifying session mode
@Inject
@JMSConnectionFactory("jms/connectionFactory")
@JMSSessionMode(JMSContext.AUTO_ACKNOWLEDGE)
private JMSContext context;
Specifying user and password (not for production use)
@Inject
@JMSConnectionFactory("jms/connectionFactory")
@JMSPasswordCredential(userName="admin",password="mypassword")
private JMSContext context;
Copyright © 2013, Oracle and/or its affiliates. 34 All rights reserved.
- 35. Injection of JMSContext objects
into a Java EE web or EJB container
l Injected JMSContext objects have a scope
In a JTA transaction, scope is the transaction
If no JTA transaction, scope is the request
l JMSContext is automatically closed when scope ends
l Inject two JMSContext objects within the same scope and you get the
same object
If @JMSConnectionFactory, @JMSPasswordCredential and
@JMSSessionMode annotations match
Makes it easier to use same session within a transaction
Copyright © 2013, Oracle and/or its affiliates. 35 All rights reserved.
- 36. The four JMS APIs
Simplified API Standard API Legacy
TopicConnection
Factory
TopicConnection
TopicSession
TopicProducer
TopicSubscriber new and
simplified slightly
Copyright © 2013, Oracle and/or its affiliates. 36 All rights reserved.
queue-specific
API
Legacy
topic-specific
API
Introduced
in
JMS 2.0 JMS 1.1 JMS 1.0 JMS 1.0
Main
interfaces
ConnectionFactory
JMSContext
JMSProducer
JMSConsumer
ConnectionFactory
Connection
Session
MessageProducer
MessageConsumer
QueueConnection
Factory
QueueConnection
QueueSession,
QueueSender,
QueueReceiver
simplified
deprecated
- 38. Delivery delay
In both the standard and simplified APIs
Allows a JMS client to schedule the future delivery of a message
New method on MessageProducer
public void setDeliveryDelay(long deliveryDelay)
New method on JMSProducer
public JMSProducer setDeliveryDelay(long deliveryDelay)
Sets minimum time in ms from that a message should be retained by the
messaging system before delivery to a consumer
Why? If the business requires deferred processing, e.g. end of day
Copyright © 2013, Oracle and/or its affiliates. 38 All rights reserved.
- 39. Async send
In both the standard and simplified APIs
l Send a message and return immediately without blocking until an
acknowledgement has been received from the server.
l Instead, when the acknowledgement is received, an asynchronous
callback will be invoked
l New methods on MessageProducer
messageProducer.send(message,completionListener)
l Feature also available on JMSProducer
l Why? Allows thread to do other work whilst waiting for the
acknowledgement
Copyright © 2013, Oracle and/or its affiliates. 39 All rights reserved.
- 40. Async send
In both the standard and simplified APIs
Application specifies a CompletionListener instance
public interface CompletionListener {
void onCompletion(Message message);
void onException(Message message, Exception exception);
}
Copyright © 2013, Oracle and/or its affiliates. 40 All rights reserved.
- 41. Better handling of "poison" messages
JMS 1.1 defines an optional JMS defined message property
JMSXDeliveryCount.
When used, this is set by the JMS provider when a message is
received, and is set to the number of times this message has been
delivered (including the first time).
JMS 2.0 will make this mandatory
Why? Allows app servers and applications to handle "poisonous"
messages better
Copyright © 2013, Oracle and/or its affiliates. 41 All rights reserved.
- 42. Multiple consumers on a
topic subscription
Copyright © 2013, Oracle and/or its affiliates. 42 All rights reserved.
- 43. How topics work in JMS 1.1
Producer Topic
Copyright © 2013, Oracle and/or its affiliates. 43 All rights reserved.
Subscription
Subscription
Consumer
Each message
is copied to
every
subscription
In JMS 1.1,
each
subscription
has a single
consumer
Subscription may
be persisted
(durable) or
memory-only
(non-durable)
Consumer
Subscription
Consumer
- 44. Shared subscriptions in JMS 2.0
Producer Topic
Copyright © 2013, Oracle and/or its affiliates. 44 All rights reserved.
Consumer
Shared Subscription
Each message
is copied to
every
subscription A shared
subscription
may have
multiple
consumers
Subscription may
be persisted
(durable) or
memory-only
(non-durable)
Unshared subscription
Consumer
Consumer
Consumer
Each message on
the shared
subscription is
delivered to only
one consumer
- 45. Easier definition of JMS
resources in Java EE
(This is actually part of
Java EE 7)
Copyright © 2013, Oracle and/or its affiliates. 45 All rights reserved.
- 46. Easier definition of JMS resources in Java EE
The problem
l Java EE and JMS recommend applications should obtain JMS
ConnectionFactory and Destination resources by lookup from JNDI
@Resource(lookupName = "jms/inboundQueue")
private Queue inboundQueue;
l Keeps application code portable
l Creating these resources is a burden on the deployer, and is non-standard
Copyright © 2013, Oracle and/or its affiliates. 46 All rights reserved.
- 47. Platform default connection factory
Making the simple case simple
If you simply want to use the application server's built-in JMS provider,
with no special settings:
@Resource(lookup="java:comp/defaultJMSConnectionFactory")
ConnectionFactory myJMScf;
Copyright © 2013, Oracle and/or its affiliates. 47 All rights reserved.
- 48. Easier definition of JMS resources in Java EE
New feature in Java EE 7
Application may specify the JMS connection factories and JMS
destinations that it needs using annotations
Copyright © 2013, Oracle and/or its affiliates. 48 All rights reserved.
@JMSDestinationDefinition(
name = "java:global/jms/myQueue",
interfaceName = "javax.jms.Queue",
destinationName = "demoQueue"
)
@JMSConnectionFactoryDefinition(
name="java:global/jms/myCF"
)
JNDI
name
JNDI
name
queue/
topic
name
- 49. Easier definition of JMS resources in Java EE
New feature in Java EE 7
Can specify additional standard or provider-specific properties
Copyright © 2013, Oracle and/or its affiliates. 49 All rights reserved.
@JMSDestinationDefinition(
name = "java:global/jms/myQueue",
interfaceName = "javax.jms.Queue",
destinationName = "demoQueue"
)
@JMSConnectionFactoryDefinition(
name="java:global/jms/myCF",
maxPoolSize = 30,
minPoolSize= 20,
properties = {
"addressList=mq://localhost:7676",
"reconnectEnabled=true"
}
)
standard
properties
non-standard
properties
- 50. Easier definition of JMS resources in Java EE
New feature in Java EE 7
Multiple definitions of same type must be wrapped in collection
annotations (due to restriction in how Java annotations work)
Copyright © 2013, Oracle and/or its affiliates. 50 All rights reserved.
@JMSDestinationDefinitions({
@JMSDestinationDefinition(
name = "java:global/jms/myQueue1",
interfaceName = "javax.jms.Queue",
destinationName = "demoQueue1"
),
@JMSDestinationDefinition(
name = "java:global/jms/myQueue2",
interfaceName = "javax.jms.Queue",
destinationName = "demoQueue2"
)
})
@JMSConnectionFactoryDefinitions({
@JMSConnectionFactoryDefinition(
name="java:global/jms/myCF1"
),
@JMSConnectionFactoryDefinition(
name="java:global/jms/myCF2"
)
})
- 51. Easier definition of JMS resources in Java EE
New feature in Java EE 7
Alternatively application may specify the JMS connection factories and
JMS destinations that it needs in the XML deployment descriptor
Copyright © 2013, Oracle and/or its affiliates. 51 All rights reserved.
<jms-destination>
<name>
java:global/jms/myQueue
</name>
<interface-name>
javax.jms.Queue
</interface-name>
<destination-name>
demoQueue
</destination-name>
</jms-destination>
<jms-connection-factory>
<name>java:global/jms/myCF</name>
<max-pool-size>30</max-pool-size>
<min-pool-size>20</min-pool-size>
<property>
<name>addressList</name>
<value>mq://localhost:7676</value>
</property>
<property>
<name>reconnectEnabled</name>
<value>true</value>
</property>
</jms-connection-factory>
- 52. Easier definition of JMS resources in Java EE
Available namespaces
Resources configured in this way must be in one of the following
namespaces:
java:comp – may be used within same component only
java:module – may be used within same module only
java:app – may be used within same application only
java:global – may be used within any application
May be referenced just like any other resource (e.g. @Resource)
@Resource(lookup="java:global/jms/myCF")
ConnectionFactory myCF;
Copyright © 2013, Oracle and/or its affiliates. 52 All rights reserved.
- 53. More standardized
configuration of JMS MDBs
Joint effort with
JSR 345 (EJB 3.2)
Copyright © 2013, Oracle and/or its affiliates. 53 All rights reserved.
- 54. More standardized configuration of JMS MDBs
l Configuration of JMS MDBs is surprisingly non-standard
l EJB 3.1 does not define how to specify
JNDI name of queue or topic (using annotation)
JNDI name of connection factory
ClientID
DurableSubscriptionName
l EJB 3.1 does not define how topic messages delivered to clustered
MDBs
Copyright © 2013, Oracle and/or its affiliates. 54 All rights reserved.
- 55. More standardized configuration of JMS MDBs
New activation property to specify the queue or topic
@MessageDriven(activationConfig = {
@ActivationConfigProperty(
propertyName = "destinationLookup",
propertyValue = "jms/myTopic"),
. . .
})
Can also be configured in ejb-jar.xml
Copyright © 2013, Oracle and/or its affiliates. 55 All rights reserved.
- 56. More standardized configuration of JMS MDBs
New activation property to specify the connection factory
@MessageDriven(activationConfig = {
@ActivationConfigProperty(
propertyName = "connectionFactoryLookup",
propertyValue = "jms/myCF"),
. . .
})
Can also be configured in ejb-jar.xml
Copyright © 2013, Oracle and/or its affiliates. 56 All rights reserved.
- 57. More standardized configuration of JMS MDBs
New activation properties to specify durable subscriptions
@MessageDriven(activationConfig = {
@ActivationConfigProperty(
propertyName = "subscriptionDurability",
propertyValue = "Durable"),
@ActivationConfigProperty(
propertyName = "clientId",
propertyValue = "myClientID"),
@ActivationConfigProperty(
propertyName = "subscriptionName",
propertyValue = "MySub"),
. . .
Surprisingly, these have never been standardized before
})
Copyright © 2013, Oracle and/or its affiliates. 57 All rights reserved.
clientId
optional even
for durable
subscriptions
- 58. What’s new in JMS 2.0
Summary
l Simplicity and ease of use
l New messaging features
l Multi-threaded topic subscribers
Delivery delay
Async send
l Better Java EE integration
Simpler resource configuration
Standardized configuration of JMS MDBs
l Minor corrections and clarifications
Copyright © 2013, Oracle and/or its affiliates. 58 All rights reserved.
- 59. Try JMS 2.0
JMS 2.0, EJB 3.2 and Java EE 7
l JMS 2.0 in a standalone provider (for Java SE applications)
Open Message Queue 5.0 mq.java.net/
l JMS 2.0 in a full Java EE 7 application server
GlassFish 4.0 glassfish.java.net/
l Try other implementations as they are released
l See also jms-spec.java.net for lots of useful links
Copyright © 2013, Oracle and/or its affiliates. 59 All rights reserved.