[jboss-user] [JBoss Messaging] - Re: Viewing message contents in a queue
parressh
do-not-reply at jboss.com
Wed May 30 11:21:28 EDT 2007
Tim, here are the details of my setup:
jboss-messaging-1.2.0.sp1
jboss-as-4.0.5.GA
MDB is configured to consume on one thread, one message at a time.
>From standardjboss.xml
| <invoker-proxy-binding>
| <name>message-driven-bean</name>
| <invoker-mbean>default</invoker-mbean>
| <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
| <proxy-factory-config>
| <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
| <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
| <CreateJBossMQDestination>true</CreateJBossMQDestination>
| <!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
| <MinimumSize>1</MinimumSize>
| <MaximumSize>1</MaximumSize>
| <KeepAliveMillis>30000</KeepAliveMillis>
| <MaxMessages>1</MaxMessages>
| <MDBConfig>
| <ReconnectIntervalSec>10</ReconnectIntervalSec>
| <DLQConfig>
| <DestinationQueue>queue/DLQ</DestinationQueue>
| <MaxTimesRedelivered>10</MaxTimesRedelivered>
| <TimeToLive>0</TimeToLive>
| </DLQConfig>
| </MDBConfig>
| </proxy-factory-config>
| </invoker-proxy-binding>
|
>From connection-factories-service.xml
| <mbean code="org.jboss.jms.server.connectionfactory.ConnectionFactory"
| name="jboss.messaging.connectionfactory:service=ConnectionFactory"
| xmbean-dd="xmdesc/ConnectionFactory-xmbean.xml">
| <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
| <depends optional-attribute-name="Connector">jboss.messaging:service=Connector,transport=bisocket</depends>
| <depends>jboss.messaging:service=PostOffice</depends>
|
| <attribute name="JNDIBindings">
| <bindings>
| <binding>/ConnectionFactory</binding>
| <binding>/XAConnectionFactory</binding>
| <binding>java:/ConnectionFactory</binding>
| <binding>java:/XAConnectionFactory</binding>
| </bindings>
| </attribute>
| <attribute name="PrefetchSize">1</attribute>
| <attribute name="Clustered">true</attribute>
| <attribute name="LoadBalancingFactory">org.jboss.jms.client.plugin.RoundRobinLoadBalancingFactory</attribute>
| </mbean>
|
Message sender code:
Following beans set by Spring:
qcf is retrieved from JNDI name XAConnectionFactory
leadQueue is retrieved from JNDI name queue/leadQueue
| public void processLead(String leadXml, int messageAttempts) {
| QueueConnection conn = null;
| try {
| conn = qcf.createQueueConnection();
| QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
| QueueSender sender = session.createSender(leadQueue);
| TextMessage msg = session.createTextMessage(leadXml);
| msg.setIntProperty(MESSAGE_ATTEMPTS_PROPERTY, messageAttempts);
| msg.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
| sender.send(msg);
| } catch (JMSException ex) {
| LeadProcessingException lpe = new LeadProcessingException(
| "Queue down: cannot send lead to Queue", ex);
| throw lpe;
| } finally {
| if (conn != null) {
| try {
| conn.close();
| } catch (Exception ex) {
| logger.error("Error disconnecting from JMS Queue", ex);
| }
| }
| }
| }
|
Simplified MDB Code:
| public void onMessage(Message msg) {
| logger.info("Processing jms message");
| String message;
| try {
| message = ((TextMessage) msg).getText();
| Thread.sleep(2000);
| } catch (Exception e) {
| throw new RuntimeException("Unable to read message text", e);
| }
| }
|
The log file shows that only one MDB is active and consuming messages once every 2 seconds.
I really appreciate your time Tim. Let me know if you need more info.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049777#4049777
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049777
More information about the jboss-user
mailing list