The consumer java code :
public class ConsumerBean implements MessageListener {
private Logger log = Logger.getLogger(getClass());
private JmsTemplate template;
private Destination destination;
private Connection connection;
private Session session;
private MessageConsumer consumer;
private String myId = "ABC";
public void start() throws JMSException {
String selector = "next = '" + myId + "'";
try {
ConnectionFactory factory = template.getConnectionFactory();
connection = factory.createConnection();
// we might be a reusable connection in spring
// so lets only set the client ID once if its not set
synchronized (connection) {
if (connection.getClientID() == null) {
connection.setClientID(myId);
}
}
connection.start();
session = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(destination, selector, false);
consumer.setMessageListener(this);
}
catch (JMSException ex) {
log.error("*** Error Starting Consumer !!!", ex);
throw ex;
}
}
/* (non-Javadoc)
* @see javax.jms.MessageListener#onMessage(javax.jms.Message)
*/
public void onMessage(Message msg) {
log.info("==> Receiving a msg to generate PDF ...");
...
}
/**
* @return the template
*/
public JmsTemplate getTemplate() {
return template;
}
/**
* @param template the template to set
*/
public void setTemplate(JmsTemplate template) {
this.template = template;
}
/**
* @return the destination
*/
public Destination getDestination() {
return destination;
}
/**
* @param destination the destination to set
*/
public void setDestination(Destination destination) {
this.destination = destination;
}
}
I think the message is consumed because the onMessage method is invoked.
James.Strachan wrote:
>
> Could you post your consumer java code?
>
> If you browse the queues, do you see messages being consumed?
> http://incubator.apache.org/activemq/jmx.html
>
>
> On 9/26/06, nusa <[EMAIL PROTECTED]> wrote:
>>
>> James,
>>
>> OK, I'm going to ignore this failover.
>>
>> Back to my consumer, I'm using a queue ( I mean that what I expected ).
>> I modified my activemq.xml into :
>> ...
>> <destinationPolicy>
>> <policyMap>
>> <policyEntries>
>> <policyEntry queue="SCANNINGDA.QUEUE>">
>> <dispatchPolicy>
>> <strictOrderDispatchPolicy />
>> </dispatchPolicy>
>> </policyEntry>
>> </policyEntries>
>> </policyMap>
>> </destinationPolicy>
>> ...
>>
>> undeploy, then deploy the war file.
>> Yet the onMessage got invoke again WITHOUT any message sent by the
>> producer.
>> Any idea James ?
>>
>> Thanks.
>>
>>
>>
>> James.Strachan wrote:
>> >
>> > On 9/26/06, nusa <[EMAIL PROTECTED]> wrote:
>> >> Thanks James for a quick reply.
>> >>
>> >> failover: is only used on the client side. How and where to define it
>> ?
>> >
>> > You only use it when configuring your JMS client - ignore it for using
>> > networkConnectors (i.e. connecting brokers to each other) as they use
>> > a failover mechanism by default
>> >
>> >
>> http://incubator.apache.org/activemq/how-can-i-support-auto-reconnection.html
>> >
>> >
>> >> OK, sorry for incomplete info.
>> >> Everytime I startup my Tomcat, my consumer receveive a message, to be
>> >> precised
>> >> the onMessage method is invoked, WITHOUT the producer send any
>> message.
>> >> Would that help ?
>> >
>> > I can't explain it I'm afraid. Are you using topics or queues? From
>> > your configuraiton you seem to be using queues with
>> > lastImageRecoveryPolicy (which is only intended for topics). If you
>> > are using last image recovery, then getting a message on startup is
>> > the desired behaviour :)
>> >
>> > --
>> >
>> > James
>> > -------
>> > http://radio.weblogs.com/0112098/
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-with-failover-and-consumer-tf2337476.html#a6504817
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>>
>
>
> --
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
--
View this message in context:
http://www.nabble.com/Problem-with-failover-and-consumer-tf2337476.html#a6504962
Sent from the ActiveMQ - User mailing list archive at Nabble.com.