camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <claus.ib...@gmail.com>
Subject Re: Schedule JMS consumer
Date Tue, 16 Dec 2008 05:13:15 GMT
Hi

The problem is that camel-quartz add objects to the exchange that is
NOT serializable and thus can not be sent to a JMS queue using
javax.jms.ObjectMessage. So we want to send some plain text instead,
as you only need it to send something so the JMS consumer will trigger
and invoke your dummy listener.

If you skip the JMS all together then I guess it should work.

However I might have made a slight mistake in the transform DSL. Let's
keep it lowlevel and try with a processor, to get around the NOT
serializable issue with Quartz and JMS.

from("quartz://myGroup/myTimerName?trigger.repeatInterval=6000&trigger.repeatCount=10").process(new
Processor() {
  public void process(Exchange exchange) {
     // replace not serializable stuff added by quartz
     exchange.getIn().setBody("Hello");
     exchange.getIn().setHeaders(null);
   })
.to("jms:queue:events");



On Tue, Dec 16, 2008 at 5:08 AM, iapilgrim <iapilgrim@gmail.com> wrote:
>
> Hi Claus,
> Thanks for your quick reply.
> I tried your hint and I got these messages
>
> org.apache.camel.NoTypeConversionAvailableException: No type converter
> available to convert from type: class
> org.apache.camel.component.jms.JmsMessage to the required type:
> org.pyco.core.linkmanagement.event.Event with value JmsMessage:
> ActiveMQTextMessage {commandId = 5, responseRequired = true, messageId =
> ID:pr-vanle-58918-1229398784102-2:11:1:1:1, originalDestination = null,
> originalTransactionId = null, producerId =
> ID:pr-vanle-58918-1229398784102-2:11:1:1, destination = queue://events,
> transactionId = null, expiration = 0, timestamp = 1229398844786, arrival =
> 0, brokerInTime = 1229398844787, brokerOutTime = 1229398844787,
> correlationId = null, replyTo = null, persistent = true, type = null,
> priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
> compressed = false, userID = null, content = null, marshalledProperties =
> null, dataStructure = null, redeliveryCounter = 0, size = 1024, properties =
> {fireTime=Tue Dec 16 10:40:44 ICT 2008, jobRunTime=-1, triggerGroup=myGroup,
> scheduledFireTime=Tue Dec 16 10:40:44 ICT 2008, previousFireTime=Tue Dec 16
> 10:40:38 ICT 2008, refireCount=0, triggerName=myTimerName},
> readOnlyProperties = true, readOnlyBody = true, droppable = false, text =
> Hello}
>
> Here my comments:
> + I don't know this error much.
> I guess I need a converter but what I need to do to make a converter. I mean
> a converter to convert hello message is no use here.
> + I don't know why we have this kind of statement.
>
> from("quartz://myGroup/myTimerName?trigger.repeatInterval=6000&trigger.repeatCount=10").transform(constant("Hello")).to("jms:queue:events");
> I have had events in my queue also ( created by producer). If I add new data
> to jms queue, only for trigger scheduler. It's weird.
> + Timer component have similar uri to quartz
>  from("timer://foo?fixedRate=true&period=6000").to("jms:queue:events");
> but it behaves as I expect. I don't know why ( i'm not clear)
> And...
> + How can I use jms converter with camel or camel-spring?
> I used jms with spring before then I have a little confused.
> + When can I use Camel 2.0?
> I have just glance over Camel 2.0 Jira, and found there are many issues have
> been fixed.
> So can I use camel source in the trunk? If yes, how can I implement schedule
> by using quartz and jms component?
>
> Many thanks,
> Van
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Ah we have some tickets in JIRA to improve the quartz component for Camel
>> 2.0.
>>
>> As you just want to use quartz to trigger the even by sending a
>> "dummy" message to a JMS queue, then you can send some sort of
>> constant body that can be serialized and send to the JMS queue
>>
>> from("quartz://myGroup/myTimerName?trigger.repeatInterval=6000&trigger.repeatCount=10").transform(constant("Hello")).
>> to("jms:queue:events");
>>
>>
>>
>> On Mon, Dec 15, 2008 at 11:49 AM, iapilgrim <iapilgrim@gmail.com> wrote:
>>>
>>> Hi,
>>> I'm very new to Camel.
>>> My situation is making scheduler for some listeners on JMS queue.
>>> For example, when I configure this way, the dummyListener will  check
>>> event
>>> in jms queue for every 6s.
>>>
>>> from("timer://foo?fixedRate=true&period=6000").to("jms:queue:events");
>>>        from("jms:queue:events").to("dummyListener");
>>> I want to improve the scheduler by replace timer with quartz
>>> from("quartz://myGroup/myTimerName?trigger.repeatInterval=6000&trigger.repeatCount=10").to("jms:queue:events");
>>>
>>> But when I run, I got the following error message
>>>
>>> [ERROR] processor.DeadLetterChannel Failed delivery for exchangeId:
>>> ID-pr-vanle/60407-1229325928115/0-2. On delivery attempt: 2 caught:
>>> java.lang.RuntimeException:
>>> org.apache.camel.component.quartz.QuartzEndpoint
>>> java.lang.RuntimeException:
>>> org.apache.camel.component.quartz.QuartzEndpoint
>>>        at
>>> org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:104)
>>>        at
>>> org.apache.activemq.command.ActiveMQObjectMessage.setObject(ActiveMQObjectMessage.java:155)
>>>        at
>>> org.apache.activemq.ActiveMQSession.createObjectMessage(ActiveMQSession.java:317)
>>>        at
>>> org.apache.camel.component.jms.JmsBinding.createJmsMessage(JmsBinding.java:273)
>>>        at
>>> org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:139)
>>>        at
>>> org.apache.camel.component.jms.JmsProducer$2.createMessage(JmsProducer.java:229)
>>>        at
>>> org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:570)
>>>        at
>>> org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:551)
>>>        at
>>> org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:471)
>>>        at
>>> org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:548)
>>>        at
>>> org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:227)
>>>        at
>>> org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
>>>        at
>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
>>>        at
>>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:57)
>>>        at
>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:155)
>>>        at
>>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:91)
>>>        at
>>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:57)
>>>        at
>>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
>>>        at
>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>>        at
>>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>>        at
>>> org.apache.camel.processor.loadbalancer.QueueLoadBalancer.process(QueueLoadBalancer.java:41)
>>>        at
>>> org.apache.camel.component.quartz.QuartzEndpoint.onJobExecute(QuartzEndpoint.java:117)
>>>        at
>>> org.apache.camel.component.quartz.CamelJob.execute(CamelJob.java:32)
>>>        at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
>>>        at
>>> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
>>> Caused by: java.io.NotSerializableException:
>>> org.apache.camel.component.quartz.QuartzEndpoint
>>>        at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
>>>        at
>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>>>        at java.util.HashMap.writeObject(HashMap.java:1001)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at
>>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
>>>        at
>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
>>>        at
>>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>>        at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>>>        at
>>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>>>        at
>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>>>        at
>>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>>        at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>>>        at
>>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
>>>        at
>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
>>>        at
>>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
>>>        at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
>>>        at
>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
>>>        at
>>> org.apache.activemq.command.ActiveMQObjectMessage.storeContent(ActiveMQObjectMessage.java:98)
>>>        ... 24 more
>>>
>>> I'm maybe wrong in using quartz and jms. Could you give any example?
>>> I'd appreciate your help.
>>> Thanks and regards,
>>> Van
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Schedule-JMS-consumer-tp21011689s22882p21011689.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Schedule-JMS-consumer-tp21011689s22882p21026931.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Mime
View raw message