yes, it is a Queue. I am a little suprised at this problem, although I have
never done a Queue before usually always dealing with topics.
I need to distribute a process. a queue with multiple consumers seemed the
perfect answer, because each task passed along could get grabbed by exactly one
consumer.
| <mbean code="org.jboss.mq.server.jmx.Queue"
| name="jboss.mq.destination:service=Queue,name=uncategorizedpages">
| <depends
optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
| </mbean>
|
The code uses Queue in the usual way:
| Context ctx = new InitialContext(config);
| QueueConnectionFactory queueFactory = (QueueConnectionFactory)
ctx.lookup("ConnectionFactory");
| Destination queueDestination = (Destination)
ctx.lookup(unitQueueName);
|
| QueueConnection queueConnection = (QueueConnection)
queueFactory.createConnection(unitQueueUser, unitPagesQueuePass);
| Session queueSession =
queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
| List<UnitVO> batch = loadBatch(0);
|
|
| // for each page in the batch
| for (UnitVO unit : batch)
| {
| MessageProducer producer =
queueSession.createProducer(queueDestination);
| producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
| ObjectMessage msg = queueSession.createObjectMessage(page);
| producer.send(msg);
| producer.close();
|
| }
| queueSession.close();
| queueConnection.close();
|
| Context ctx = new InitialContext(this.config);
| QueueConnectionFactory queueConnnectionFactory =
(QueueConnectionFactory) ctx.lookup(connectionFactoryJNDIName);
| QueueConnection queueConnection =
queueConnnectionFactory.createQueueConnection(unitQueueUser, unitQueuePass);
| QueueSession unitSession =
| queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
| Queue unitQueue =
| (Queue) ctx.lookup(unitQueueName);
| QueueReceiver receiver =
| unitSession.createReceiver(unitQueue);
| queueConnection.start();
|
|
| // until we are told to stop
| while (!shutdown)
| {
| Message msg = receiver.receive(1000);
|
| if (msg != null && msg instanceof ObjectMessage)
| {
| UnitVO page = (UnitVO) ((ObjectMessage)
msg).getObject();
| System.out.println(unit.getId());
| }
| else {
| shutdown=true;
| }
| }
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884549#3884549
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884549
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user