Professional Documents
Culture Documents
JBossMQ
Messaging, JMS, JBossMQ Architecture, Advanced Configuration and Tuning
Topics
Professional Open Source™
JBossMQ
– Architectural Overview
– The Inflow of a message through JBossMQ
– JBossMQ Components
– JBossMQ Configuration
– JBossMQ Fine Tuning
1
The Need for Messaging
Professional Open Source™
File Transfer
– One application writes to a file and another application reads from the file.
The applications need to agree on location, format and timing.
Shared Database
– Multiple applications share the same database schema and a single
physical database.
Remote Procedure Invocation
– One application exposes functionality that can be accessed remotely and
synchronously.
Messaging
– One application sends a message to a provider, another application
asynchronously reads the message from the provider at a later time.
Web Services
Messaging Pros
Professional Open Source™
2
Messaging Cons
Professional Open Source™
The Java API that allows applications to create, send, receive and
read messages
3
JMS Messaging Domains
Professional Open Source™
Message
Sender m1
Sender m7
m7 Receiver
Receiver
se
nd Queue
Queue rec
eiv
e
Sender
Sender m6 m5 m4 m3
Receiver
Receiver
m2
re
ce
Sender
Sender iv
e Receiver
Receiver
Message m1
Sender
Sender m1 Receiver
Receiver
e iv e
se rec
nd Topic m1
Topic
Sender
Sender Receiver
Receiver
receive
m1
Sender
Sender re
ce
iv Receiver
Receiver
e
QueueConnectionFactory
QueueConnectionFactory ConnectionFactory
ConnectionFactory TopicConnectionFactory
TopicConnectionFactory
QueueConnection
QueueConnection Connection
Connection TopicConnection
TopicConnection
QueueSession
QueueSession Session
Session TopicSession
TopicSession
QueueSender
QueueSender QueueReceiver
QueueReceiver MessageProducer
MessageProducer MessageConsumer
MessageConsumer TopicPublisher
TopicPublisher TopicSubscriber
TopicSubscriber
creates
Message
Message
Queue
Queue Destination
Destination Topic
Topic
4
Reliability and JMS
Professional Open Source™
JBossMQ Features
Professional Open Source™
JBossMQ Features
– Fire-and-forget for asynchronous delivery
– Guaranteed Delivery using persistent messages and durable
subscriptions
– Dead Letter Queue (DLQ)
– Pluggable Invocation Layers to support different transport protocols
(TCP/IP, HTTP, in-memory invocations)
– Pluggable Security
– Pluggable Persistence
– JTA XA integration used by JBoss’ JMS resource adapter
– High Availability in a clustered environment
5
JBossMQ – An Architectural Overview
Professional Open Source™
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
JBossMQ VM
© JBoss, Inc. 2003-2005. 11
6
The inflow of a message through JBossMQ
Professional Open Source™
1. Sending
the message
on the client
side
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
JBossMQ VM
© JBoss, Inc. 2003-2005. 13
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
JBossMQ VM
© JBoss, Inc. 2003-2005. 14
7
The inflow of a message through JBossMQ
Professional Open Source™
2. The ConnectionFactory.
1. Sending - How does it get bound in
the message JNDI?
on the client
side
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
JBossMQ VM
© JBoss, Inc. 2003-2005. 15
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
JBossMQ VM
© JBoss, Inc. 2003-2005. 16
8
The inflow of a message through JBossMQ
Professional Open Source™
2. The ConnectionFactory.
1. Sending 4. The Invoker and
- How does it get bound in
the message the interceptor chain
JNDI?
on the client
side
ConnectionFactory
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ
JBossMQ VM security
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ
JBossMQ VM security
9
The inflow of a message through JBossMQ
Professional Open Source™
2. The ConnectionFactory.
1. Sending 4. The Invoker and
- How does it get bound in
the message the interceptor chain 7. Deploying a
JNDI?
on the client destination
side
6. The
ConnectionFactory DestinationManager
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
Remote Client VM
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ
JBossMQ VM security
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
8. Configuring
Remote Client VM the message
softening
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ
JBossMQ VM security
10
The inflow of a message through JBossMQ
Professional Open Source™
2. The ConnectionFactory.
1. Sending 4. The Invoker and
- How does it get bound in
the message the interceptor chain 7. Deploying a
JNDI?
on the client destination
side
6. The
ConnectionFactory DestinationManager
ConnectionFactory HTTP
HTTPILIL
Service
Service
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Producer Unified Invocation Layer
…..
UIL2 JMSDestination
JMSDestination MDB
MDB
Session
Session Connection
Connection UIL2
Invoker Manager
Manager Container
Container
Service
Service Invoker JMSTopic
JMSTopic
Tracing
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
8. Configuring
Remote Client VM the message
softening
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ 9. Configuring
JBossMQ VM security the persistence
JMSQueue
ServerSecurityInterceptor
JMSQueue
ServerSecurityInterceptor
Interceptor
Producer
TracingInterceptor
Consumer
Consumer
JMSTopic
JMSTopic
JVM
JVMILIL
Service
Service
8. Configuring
Remote Client VM the message
softening
Security
Security State
State Message
Message
Manager
Manager Manager
Manager Cache
Cache
3. The Invocation Layers.
- How do they work?
- How to deploy them?
- How to configure them?
- How to secure them? Persistence
Persistence
JaasSecurityManager
JaasSecurityManager Manager
Manager
5. Configuring
the JBossMQ 9. Configuring
JBossMQ VM security the persistence
11
The Client Side
Professional Open Source™
To send/receive a message
– Look-up the ConnectionFactory and the Destination.
– Create a Connection, Session a MessageProducer and a
MessageConsumer.
– If you want to send messages, don’t forget to start() the Connection!
import
import javax.jms.*;
javax.jms.*;
public
public static
static void
void main(String[]
main(String[] args)
args) throws
throws Exception
Exception {{
Context
Context context
context == new
new InitialContext();
InitialContext();
ConnectionFactory
ConnectionFactory connectionFactory
connectionFactory == (ConnectionFactory)context.lookup("ConnectionFactory");
(ConnectionFactory)context.lookup("ConnectionFactory");
Destination
Destination topic
topic == (Destination)context.lookup(“topic/MyTopic”);
(Destination)context.lookup(“topic/MyTopic”);
Connection
Connection connection
connection == connectionFactory.createConnection();
connectionFactory.createConnection();
Session
Session session
session == connection.createSession(true,
connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
Session.AUTO_ACKNOWLEDGE);
MessageProducer
MessageProducer producer
producer == session.createProducer(topic);
session.createProducer(topic);
TextMessage
TextMessage textMessage = session.createTextMessage(“some text”);
textMessage = session.createTextMessage(“some text”);
connection.start();
connection.start();
producer.send(textMessage);
producer.send(textMessage);
connection.close();
connection.close();
}}
The ConnectionFactory
Professional Open Source™
A ConnectionFactory
– Is a JMS Administered Object.
– Encapsulates a set of connection configuration parameters that has been
defined by the JMS server administrator.
– A client uses it to create a connection with a JMS provider.
12
The Invocation Layers
Professional Open Source™
Available implementations:
– Unified Invocation Layer Version 2 (UIL2)
– HTTPIL
– JVMIL
Socket
Socket Socket
Socket JMSServerInvoker
JMSServerInvoker
Connection
Connection Manager
Manager Manager
Manager
UILClientILService
UILClientILService UILServerIL
UILServerIL
13
UIL2 Deployment and Configuration
Professional Open Source™
<?xml
<?xml version="1.0"
version="1.0" encoding="UTF-8"?>
encoding="UTF-8"?>
<server>
<server>
<mbean
<mbean code="org.jboss.mq.il.uil2.UILServerILService“
code="org.jboss.mq.il.uil2.UILServerILService“
name="jboss.mq:service=InvocationLayer,type=UIL2">
name="jboss.mq:service=InvocationLayer,type=UIL2">
<!--
<!-- The
The server
server chain
chain -->
-->
<depends
<depends optional-attribute-name="Invoker">jboss.mq:service=Invoker</depends>
optional-attribute-name="Invoker">jboss.mq:service=Invoker</depends>
<!--
<!-- JNDI
JNDI binding
binding -->
-->
<attribute
<attribute name="ConnectionFactoryJNDIRef">ConnectionFactory</attribute>
name="ConnectionFactoryJNDIRef">ConnectionFactory</attribute>
<!--
<!-- JNDI
JNDI binding
binding for
for XA
XA -->
-->
<attribute
<attribute name="XAConnectionFactoryJNDIRef">XAConnectionFactory</attribute>
name="XAConnectionFactoryJNDIRef">XAConnectionFactory</attribute>
<!--
<!-- The
The bind
bind address
address -->
-->
<attribute
<attribute name="BindAddress">${jboss.bind.address}</attribute>
name="BindAddress">${jboss.bind.address}</attribute>
(continued
(continued …)
…)
(…
(… continued)
continued)
<!--
<!-- The
The bind
bind port
port -->
-->
<attribute
<attribute name="ServerBindPort">8093</attribute>
name="ServerBindPort">8093</attribute>
<!--
<!-- The
The ping
ping period
period in
in millis
millis -->
-->
<attribute
<attribute name="PingPeriod">60000</attribute>
name="PingPeriod">60000</attribute>
<!--
<!-- Whether
Whether tcp/ip
tcp/ip does
does not
not wait
wait for
for buffer
buffer fills
fills -->
-->
<attribute
<attribute name="EnableTcpNoDelay">true</attribute>
name="EnableTcpNoDelay">true</attribute>
<!--
<!-- Used
Used to
to disconnect
disconnect thethe client
client ifif there
there is
is no
no activity
activity -->
-->
<!--
<!-- Ensure
Ensure this
this is
is greater
greater than
than the
the ping
ping period
period -->
-->
<attribute
<attribute name="ReadTimeout">120000</attribute>
name="ReadTimeout">120000</attribute>
<!--
<!-- The
The size
size of
of the
the buffer
buffer (in
(in bytes)
bytes) wrapping
wrapping the
the socket
socket -->
-->
<!--
<!-- The
The buffer
buffer is
is flushed
flushed after
after each
each request
request -->
-->
<attribute
<attribute name="BufferSize">2048</attribute>
name="BufferSize">2048</attribute>
<!--
<!-- Large
Large messages
messages may may block
block the
the ping/pong
ping/pong -->
-->
<!--
<!-- AA pong
pong is
is simulated
simulated after
after each
each chunk
chunk (in
(in bytes)
bytes) for
for both
both reading
reading and
and writing
writing -->
-->
<!--
<!-- ItIt must
must be
be larger
larger than
than the
the buffer
buffer size
size -->
-->
<attribute
<attribute name="ChunkSize">1000000</attribute>
name="ChunkSize">1000000</attribute>
</mbean>
</mbean>
</server>
</server>
14
UIL2 Configuration (1)
Professional Open Source™
ConnectionFactoryJNDIRef
– The JNDI name used to bind the ConnectionFactory corresponding to this
IL.
XAConnectionFactoryJNDIRef
– The JNDI name used to bind the XAConnectionFactory corresponding to
this IL.
BindAddress
– The interface to bind to.
– Useful for a multihomed machine.
ServerBindPort
– The port UIL2 service will listen on.
PingPeriod
– The interval, in milliseconds, after which the client sends a ping message
to the server to validate the connection.
– A zero value disables pinging.
EnableTcpNoDelay
– If enabled, the socket sends a TCP/IP packet as soon as the request is flushed,
without waiting to fill the buffer.
– Improves the request response time.
ReadTimeout
– The period, in milliseconds, passed as SoTimeout value to the UIL2 socket. This
allows detection of dead sockets.
– This value must be larger than the PingPeriod.
ServerSocketFactory
– The javax.net.ServerSocketFactory class to be used to create the service's
ServerSocket.
– Typically used to secure the connection using SSL sockets.
ClientSocketFactory
– The javax.net.ServerSocketFactory class to be used to create the client sockets.
– Typically used to secure the connection using SSL sockets.
SecurityDomain
– Specifies the JNDI name of the JBoss security domain to use with JBoss SSL
aware socket factories.
15
Securing the UIL2 (1)
Professional Open Source™
>> keytool
keytool -genkey
-genkey -alias
-alias jbossmq
jbossmq -keyalg
-keyalg RSA
RSA -keystore
-keystore jbossmq.keystore
jbossmq.keystore -validity
-validity 3650
3650
<?xml
<?xml version="1.0"
version="1.0" encoding="UTF-8"?>
encoding="UTF-8"?>
<server>
<server>
<mbean
<mbean code="org.jboss.security.plugins.JaasSecurityDomain"
code="org.jboss.security.plugins.JaasSecurityDomain"
name="jboss.security:service=JaasSecurityDomain,domain=SSL">
name="jboss.security:service=JaasSecurityDomain,domain=SSL">
<constructor>
<constructor>
<arg
<arg type="java.lang.String"
type="java.lang.String" value="SSL"/>
value="SSL"/>
</constructor>
</constructor>
<attribute
<attribute name="KeyStoreURL">resource:jbossmq.keystore</attribute>
name="KeyStoreURL">resource:jbossmq.keystore</attribute>
<attribute
<attribute name="KeyStorePass">jbossmq</attribute>
name="KeyStorePass">jbossmq</attribute>
</mbean>
</mbean>
</server>
</server>
<?xml
<?xml version="1.0"
version="1.0" encoding="UTF-8"?>
encoding="UTF-8"?>
<server>
<server>
<mbean
<mbean code="org.jboss.mq.il.uil2.UILServerILService"
code="org.jboss.mq.il.uil2.UILServerILService"
name="jboss.mq:service=InvocationLayer,type=UIL2">
name="jboss.mq:service=InvocationLayer,type=UIL2">
….
….
<!--
<!-- SSL
SSL Socket
Socket Factories
Factories -->
-->
<attribute
<attribute name="ClientSocketFactory">org.jboss.security.ssl.ClientSocketFactory</attribute>
name="ClientSocketFactory">org.jboss.security.ssl.ClientSocketFactory</attribute>
<attribute
<attribute name="ServerSocketFactory">org.jboss.security.ssl.DomainServerSocketFactory</attribute>
name="ServerSocketFactory">org.jboss.security.ssl.DomainServerSocketFactory</attribute>
<!--
<!-- The
The SSL-aware
SSL-aware security
security domain
domain -->
-->
<attribute
<attribute name="SecurityDomain">java:/jaas/SSL</attribute>
name="SecurityDomain">java:/jaas/SSL</attribute>
</mbean>
</mbean>
</server>
</server>
16
Securing the UIL2 (3)
Professional Open Source™
>> keytool
keytool -export
-export -alias
-alias jbossmq
jbossmq -keystore
-keystore jbossmq.keystore
jbossmq.keystore -rfc
-rfc -file
-file jbossmq.cer
jbossmq.cer
Enter
Enter keystore
keystore password:
password: jbossmq
jbossmq
...
...
>> keytool
keytool -import
-import -alias
-alias jbossmq
jbossmq -file
-file jbossmq.cer
jbossmq.cer -keystore
-keystore jbossmq.truststore
jbossmq.truststore
Enter
Enter keystore
keystore password:
password: jbossmq
jbossmq
...
...
The Invoker
Professional Open Source™
HTTP
HTTP IL
IL
ServerSecurityInterceptor
ServerSecurityInterceptor
Service
Service
TracingInterceptor
TracingInterceptor
HTTP
HTTP IL
IL JMSDestination
JMSDestination
JMSServerInvoker
JMSServerInvoker
Service
Service Manager
Manager
HTTP
HTTP IL
IL
Service
Service
17
The Interceptor Chain
Professional Open Source™
18
The Security Manager
Professional Open Source™
Authentication (1)
Professional Open Source™
….
….
<application-policy
<application-policy name
name == "jbossmq">
"jbossmq">
<authentication>
<authentication>
<login-module
<login-module code
code == "org.jboss.security.auth.spi.DatabaseServerLoginModule"
"org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag
flag == "required">
"required">
<module-option
<module-option name
name == "unauthenticatedIdentity">guest</module-option>
"unauthenticatedIdentity">guest</module-option>
<module-option
<module-option name
name == "dsJndiName">java:/DefaultDS</module-option>
"dsJndiName">java:/DefaultDS</module-option>
<module-option name = "principalsQuery">
<module-option name = "principalsQuery">
SELECT
SELECT PASSWD
PASSWD FROMFROM JMS_USERS
JMS_USERS WHERE
WHERE USERID=?</module-option>
USERID=?</module-option>
<module-option
<module-option name
name == "rolesQuery">
"rolesQuery">
SELECT
SELECT ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
</login-module>
</login-module>
</authentication>
</authentication>
</application-policy>
</application-policy>
….
….
19
Authentication (2)
Professional Open Source™
….
….
<application-policy
<application-policy name
name == "jbossmq">
"jbossmq">
<authentication>
<authentication>
<login-module code = "org.jboss.mq.sm.file.DynamicLoginModule"
<login-module code = "org.jboss.mq.sm.file.DynamicLoginModule"
flag
flag == "required">
"required">
<module-option
<module-option name
name == "unauthenticatedIdentity">guest</module-option>
"unauthenticatedIdentity">guest</module-option>
<module-option
<module-option name
name == "sm.objectname">jboss.mq:service=StateManager</module-option>
"sm.objectname">jboss.mq:service=StateManager</module-option>
</login-module>
</login-module>
</authentication>
</authentication>
</application-policy>
</application-policy>
….
….
Authorization
Professional Open Source™
….
….
<mbean
<mbean code="org.jboss.mq.server.jmx.Queue"
code="org.jboss.mq.server.jmx.Queue"
name="jboss.mq.destination:service=Queue,name=testQueue">
name="jboss.mq.destination:service=Queue,name=testQueue">
....
....
<attribute
<attribute name="SecurityConf">
name="SecurityConf">
<security>
<security>
<role
<role name="guest"
name="guest" read="true"
read="true" write="true"/>
write="true"/>
<role
<role name="publisher"
name="publisher" read="true"
read="true" write="true"
write="true" create="false"/>
create="false"/>
</security>
</security>
</attribute>
</attribute>
</mbean>
</mbean>
….
….
20
The Destination Manager
Professional Open Source™
ServerSecurityInterceptor
destinations
ServerSecurityInterceptor
JMSQueue
JMSQueue
Interceptor
TracingInterceptor
…..
JMSTopic
JMSTopic
Tracing
JMSDestination
JMSDestination
Manager JMSTopic
JMSTopic
Manager
State
State Message
Message Persistence
Persistence
Manager
Manager Cache
Cache Manager
Manager
Destinations
Professional Open Source™
21
A Destination Deployment Descriptor
Professional Open Source™
Message Caching
Professional Open Source™
22
Message Softening
Professional Open Source™
<mbean
<mbean code="org.jboss.mq.server.MessageCache"
code="org.jboss.mq.server.MessageCache"
name="jboss.mq:service=MessageCache">
name="jboss.mq:service=MessageCache">
<attribute
<attribute name="HighMemoryMark">50</attribute>
name="HighMemoryMark">50</attribute>
<attribute
<attribute name="MaxMemoryMark">60</attribute>
name="MaxMemoryMark">60</attribute>
<attribute
<attribute name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
</mbean>
</mbean>
sender.send(message,
sender.send(message, DeliveryMode.PERSISTENT,
DeliveryMode.PERSISTENT, priority,
priority, 0);
0);
Note! the Null Persistence Manager doesn't offer you any protection from
running out of memory, since it "persists" messages in ... memory.
23
The JDBC Persistence Manager
Professional Open Source™
<mbean
<mbean code="org.jboss.mq.pm.jdbc2.PersistenceManager“
code="org.jboss.mq.pm.jdbc2.PersistenceManager“
name="jboss.mq:service=PersistenceManager">
name="jboss.mq:service=PersistenceManager">
<depends
<depends optional-attribute-name="ConnectionManager">jboss.jca:service=LocalTxCM,name=DefaultDS
optional-attribute-name="ConnectionManager">jboss.jca:service=LocalTxCM,name=DefaultDS
</depends>
</depends>
<attribute
<attribute name="SqlProperties">
name="SqlProperties">
……
</attribute>
</attribute>
</mbean>
</mbean>
<attribute
<attribute name="SqlProperties">
name="SqlProperties">
BLOB_TYPE=OBJECT_BLOB
BLOB_TYPE=OBJECT_BLOB
INSERT_TX
INSERT_TX == INSERT
INSERT INTO
INTO JMS_TRANSACTIONS
JMS_TRANSACTIONS (TXID) (TXID) values(?)
values(?)
INSERT_MESSAGE
INSERT_MESSAGE == INSERT
INSERT INTO
INTO JMS_MESSAGES
JMS_MESSAGES (MESSAGEID,
(MESSAGEID, DESTINATION,
DESTINATION, \\
MESSAGEBLOB,
MESSAGEBLOB, TXID, TXID, TXOP)
TXOP) VALUES(?,?,?,?,?)
VALUES(?,?,?,?,?)
SELECT_ALL_UNCOMMITED_TXS
SELECT_ALL_UNCOMMITED_TXS == SELECT SELECT TXID
TXID FROM
FROM JMS_TRANSACTIONS
JMS_TRANSACTIONS
SELECT_MAX_TX
SELECT_MAX_TX == SELECT
SELECT MAX(TXID)
MAX(TXID) FROM
FROM JMS_MESSAGES
JMS_MESSAGES
SELECT_MESSAGES_IN_DEST
SELECT_MESSAGES_IN_DEST == SELECT SELECT MESSAGEID,
MESSAGEID, MESSAGEBLOB
MESSAGEBLOB FROM FROM JMS_MESSAGES
JMS_MESSAGES \\
WHERE
WHERE DESTINATION=?
DESTINATION=?
SELECT_MESSAGE
SELECT_MESSAGE == SELECT
SELECT MESSAGEID,
MESSAGEID, MESSAGEBLOB
MESSAGEBLOB FROM FROM JMS_MESSAGES
JMS_MESSAGES \\
WHERE
WHERE MESSAGEID=?
MESSAGEID=? AND AND DESTINATION=?
DESTINATION=?
MARK_MESSAGE
MARK_MESSAGE == UPDATE
UPDATE JMS_MESSAGES
JMS_MESSAGES SET SET TXID=?,
TXID=?, TXOP=?
TXOP=? \\
WHERE MESSAGEID=? AND DESTINATION=?
WHERE MESSAGEID=? AND DESTINATION=?
UPDATE_MESSAGE
UPDATE_MESSAGE == UPDATE
UPDATE JMS_MESSAGES
JMS_MESSAGES SET SET MESSAGEBLOB=?
MESSAGEBLOB=? \\
WHERE
WHERE MESSAGEID=?
MESSAGEID=? AND AND DESTINATION=?
DESTINATION=?
UPDATE_MARKED_MESSAGES
UPDATE_MARKED_MESSAGES == UPDATE UPDATE JMS_MESSAGES
JMS_MESSAGES SET SET TXID=?,
TXID=?, TXOP=?
TXOP=? WHERE
WHERE TXOP=?
TXOP=?
UPDATE_MARKED_MESSAGES_WITH_TX
UPDATE_MARKED_MESSAGES_WITH_TX == UPDATE UPDATE JMS_MESSAGES
JMS_MESSAGES SET SET TXID=?,
TXID=?, TXOP=?
TXOP=? \\
WHERE
WHERE TXOP=?
TXOP=? ANDAND TXID=?
TXID=?
DELETE_MARKED_MESSAGES_WITH_TX
DELETE_MARKED_MESSAGES_WITH_TX == DELETE DELETE FROM
FROM JMS_MESSAGES
JMS_MESSAGES WHERE WHERE TXOP=?
TXOP=? AND
AND \\
JMS_MESSAGES.TXID
JMS_MESSAGES.TXID IN IN (SELECT
(SELECT TXID
TXID FROM
FROM JMS_TRANSACTIONS)
JMS_TRANSACTIONS)
DELETE_TX
DELETE_TX == DELETE
DELETE FROM
FROM JMS_TRANSACTIONS
JMS_TRANSACTIONS WHERE WHERE TXID
TXID == ??
DELETE_MARKED_MESSAGES
DELETE_MARKED_MESSAGES == DELETE DELETE FROM
FROM JMS_MESSAGES
JMS_MESSAGES WHERE WHERE TXID=?
TXID=? AND
AND TXOP=?
TXOP=?
DELETE_TEMPORARY_MESSAGES
DELETE_TEMPORARY_MESSAGES == DELETE DELETE FROM
FROM JMS_MESSAGES
JMS_MESSAGES WHERE WHERE TXOP='T'
TXOP='T'
DELETE_MESSAGE
DELETE_MESSAGE == DELETE
DELETE FROM
FROM JMS_MESSAGES
JMS_MESSAGES WHEREWHERE MESSAGEID=?
MESSAGEID=? AND AND DESTINATION=?
DESTINATION=?
CREATE_MESSAGE_TABLE
CREATE_MESSAGE_TABLE == CREATE CREATE CACHED
CACHED TABLE
TABLE JMS_MESSAGES
JMS_MESSAGES (( MESSAGEID
MESSAGEID INTEGER
INTEGER NOT
NOT NULL,
NULL, \\
DESTINATION
DESTINATION VARCHAR(255)
VARCHAR(255) NOT NOT NULL,
NULL, TXID
TXID INTEGER,
INTEGER, TXOP
TXOP CHAR(1),
CHAR(1), \\
MESSAGEBLOB
MESSAGEBLOB OBJECT,
OBJECT, PRIMARY
PRIMARY KEY KEY (MESSAGEID,
(MESSAGEID, DESTINATION)
DESTINATION) ))
CREATE_TX_TABLE
CREATE_TX_TABLE == CREATE
CREATE CACHED
CACHED TABLE
TABLE JMS_TRANSACTIONS
JMS_TRANSACTIONS (( TXID TXID INTEGER,
INTEGER, PRIMARY
PRIMARY KEY
KEY (TXID)
(TXID) ))
CREATE_TABLES_ON_STARTUP
CREATE_TABLES_ON_STARTUP == TRUE TRUE
</attribute>
</attribute>
24
The MDB Container
Professional Open Source™
JVMClientIL
JVMClientIL
….. …..
YourMDB
StdServerSession
StdServerSession
MessageListenerImpl MessageDrivenInstancePool
25
High Availability JBossMQ
Professional Open Source™
Node
Node 22
Node
Node 33 Node
Node 22 Node
Node 33
JBossMQ
JBossMQ
Singleton Fail-Over
Node
Node 11 Node
Node 11
JBossMQ
JBossMQ JBossMQ
JBossMQ
HA JBossMQ Features
Professional Open Source™
26
HA JBossMQ Deployment
Professional Open Source™
All nodes in the cluster must be configured identically in regard to the JMS
services and their persistent DataSource.
Services to configure:
– The Persistence Manager (described previously). The default configuration file is
‘server/all/deploy-hasingleton/jms/hsqldb-jdbc2-service.xml’.
– The Sate Manager (described previously. The default configuration file is
‘server/all/deploy-hasingleton/jms/hsqldb-jdbc-state-service.xml’.
…
…
private
private void
void connect(Context
connect(Context context,
context, String
String topicName)
topicName) throws
throws Exception
Exception {{
ConnectionFactory
ConnectionFactory connectionFactory
connectionFactory == (ConnectionFactory)context.lookup("ConnectionFactory");
(ConnectionFactory)context.lookup("ConnectionFactory");
connection
connection == connectionFactory.createConnection();
connectionFactory.createConnection();
connection.setExceptionListener(new
connection.setExceptionListener(new FailoverListener());
FailoverListener());
Session
Session session
session == connection.createSession(false,
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Session.AUTO_ACKNOWLEDGE);
....
....
connection.start();
connection.start();
}}
(continued
(continued …)
…)
27
Client-side fail-over detection
Professional Open Source™
(…
(… continued)
continued)
private
private class
class FailoverListener
FailoverListener implements
implements ExceptionListener
ExceptionListener {{
private
private static
static final
final int
int RETRIES
RETRIES == 5;
5;
public
public void
void onException(JMSException
onException(JMSException e)
e) {{
int
int retries
retries == RETRIES;
RETRIES;
while(retries--
while(retries-- >> 0)
0) {{
try
try {{
connection.close();
connection.close(); //// unregisters
unregisters the
the ExceptionListener
ExceptionListener
}}
catch(Exception
catch(Exception e2) e2) {{
//// II will
will get
get an
an Exception
Exception anyway,
anyway, since
since the
the connection
connection to
to the
the server
server is
is
//// broken,
broken, butbut disconnect()
disconnect() frees
frees up
up resouces
resouces associated
associated with
with the
the connection
connection
}}
try
try {{
connect(jndiContext,
connect(jndiContext, TOPIC_NAME);
TOPIC_NAME);
break;
break;
}}
catch(Exception
catch(Exception e2) e2) {{
e.printStackTrace();
e.printStackTrace();
}}
}}
}}
}}
JBossMQ Anti-Patterns
Professional Open Source™
28
What is next?
Professional Open Source™
While still one of the best open source JMS providers around,
JBossMQ could be still further improved in regards of:
– Performance
– High Availability features.
29