Sylvester,

looking at the ERROR message I think your problem is in your bean
message handling.

> ERROR - BeanComponent                  - Error processing exchange InOnly[
>  id: ID:192.168.2.79-11eca8c7aa4-2:9
>  status: Done
>  role: consumer
>  interface: {http://test2}myMailService3
>  service: {http://test2}myMailService3
>  endpoint: senderEndpoint123

This is the DONE receipt of your mail sender sent back to your bean
component after sending the mail successfully.
The problem seems to be that you take this receipt and send again a
message to the sender.

Please do the following:
In your process() method you need to distinguish between the
ExchangeStatus of the message exchange. So you should check in that
method if the exchange you received is still active or just a DONE,
ERROR or FAULT.

Use some snippet like this:

if (exchange.getStatus() == ExchangeStatus.DONE) {
   // this message exchange is a DONE receipt from a service I called
(here the mail sender)
   // do whatever you need to do here
   return;
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
   // this message exchange is an ERROR message from the mail sender
because it was unable to send the mail
   // do whatever you need to do here
   return;
} else if (exchange.getFault() != null) {
   // this is a fault message
   exchange.setStatus(ExchangeStatus.DONE);
   channel.send(exchange);
} else {
   // this is a message from the mail poller. the exchange status is ACTIVE

   QName name= new QName("http://test2","myMailService3"; ); //this is the sender
   MessageExchange exchange2 =
channel.createExchangeFactory(name).createInOnlyExchange();
   MessageUtil.transferInToIn(exchange, exchange2);
   exchange2.setService(name);

   System.out.println("Sending exchange to sender endpoint");
   // you use send here which is asynchron...that means it will not
block here until the exchange was
   // processed by the target service...the DONE or ERROR will be
processed later also with this method
   // if you use sendSync, it will block here and no DONE or ERROR
will reenter this method. you can check the
   // exchange right after the call to sendSync for the result
   channel.send(exchange2);
   System.out.println("Sent exchange to sender endpoint");

   exchange.setStatus(ExchangeStatus.DONE); //the poller
   System.out.println("Sending exchange to usual endpoint");
   channel.send(exchange);
   System.out.println("Sent exchange to usual endpoint");
}

The other possibility would be the below code (here you could leave
the checks from above away):

   QName name= new QName("http://test2","myMailService3"; ); //this is the sender
   MessageExchange exchange2 =
channel.createExchangeFactory(name).createInOnlyExchange();
   MessageUtil.transferInToIn(exchange, exchange2);
   exchange2.setService(name);

   System.out.println("Sending exchange to sender endpoint");
   if (channel.sendSync(exchange2)) {
      // the exchange was sent and the answer received
      if (exchange2.getStatus() != ERROR) {
         System.out.println("Sent exchange to sender endpoint");
         exchange.setStatus(ExchangeStatus.DONE); //the poller
         System.out.println("Sending exchange to usual endpoint");
         channel.send(exchange);
         System.out.println("Sent exchange to usual endpoint");
      } else {
         // the mail sender was not able to send the mail
         // so also set the original exchange to error
         System.out.println("Received error from the mail sender...");
         exchange.setError(exchange2.getError());
         exchange.setStatus(ExchangeStatus.ERROR);
         channel.send(exchange);
      }
   } else {
      // the mail sender was not able to send the mail
      // so also set the original exchange to error
      System.out.println("Unable to contact the mail sender...");
      exchange.setError(exchange2.getError());
      exchange.setStatus(ExchangeStatus.ERROR);
      channel.send(exchange);
   }

Hope this helps.

Regards
Lars











2009/1/13 Sylvester Steele <[email protected]>:
>
> Hi,
> I seem to be running into the same date parse exception with the
>
> Mail Poller Endpoint --> Bean Endpoint --> Mail Sender Endpoint
>
> approach when I use the 2008.01 version. I tried setting the required
> properties to null / not setting to null either way I got the Date parse
> exception.
>
>
>
>
>
> When I used the 2008.02 I get: (summary at end)
>
> ERROR - BeanComponent                  - Error processing exchange InOnly[
>  id: ID:192.168.2.79-11eca8c7aa4-2:9
>  status: Done
>  role: consumer
>  interface: {http://test2}myMailService3
>  service: {http://test2}myMailService3
>  endpoint: senderEndpoint123
>  in: Unable to display: org.xml.sax.SAXParseException: Content is not
> allowed i
> n prolog.
> ]
> javax.jbi.messaging.MessagingException: illegal call to send / sendSync
>        at
> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
> ssageExchangeImpl.java:614)
>        at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
> ryChannelImpl.java:386)
>
> If I set the mentioned properties to null I get the above exception and the
> sender emails repeatedly.
> If I do not set the mentioned properties to null I get the above exception
> but no email is sent.
>
>
> Relevant bits from my Bean SU:
>
>
> Setting properties to null:
>
>   message.setProperty("org.apache.servicemix.mail.from", null);
>        message.setProperty("org.apache.servicemix.mail.to", null);
>        message.setProperty("org.apache.servicemix.mail.cc", null);
>        message.setProperty("org.apache.servicemix.mail.bcc", null);
>        message.setProperty("org.apache.servicemix.mail.replyto", null);
>
> Sending exchange to poller and sender:
>
>
>  QName name= new QName("http://test2","myMailService3"; ); //this is the
> sender
>
>        MessageExchangeFactory
> messageExchangeFactory=channel.createExchangeFactory(name);
>        MessageExchange exchange2=
> messageExchangeFactory.createInOnlyExchange();
>        MessageUtil.transferInToIn(exchange, exchange2);
>        exchange2.setService(name);
>
>        System.out.println("Sending exchange to sender endpoint");
>        channel.send(exchange2);
>        System.out.println("Sent exchange to sender endpoint");
>
>
>        exchange.setStatus(ExchangeStatus.DONE); //the poller
>        System.out.println("Sending exchange to usual endpoint");
>        channel.send(exchange);
>        System.out.println("Sent exchange to usual endpoint");
>
>
> Summary:
>
> using 2008.01- no email sent
> using 2008.02- repeated email + exception if properties set to null in the
> Bean SU. Exception but no email if properties not set to null.
>
> What am I missing here?
>
> Thanks,
> Sylvester
>
>
> lhein wrote:
>>
>> Well...you should be able to set them to NULL.
>> That should do the trick I think.
>>
>> Regards
>> Lars
>>
>>
>> 2009/1/12 Sylvester <[email protected]>:
>>> Hi,
>>>>
>>>> The bean endpoint should remove the following properties before
>>>> forwarding the exchange to the mail sender:
>>>>
>>>> org.apache.servicemix.mail.to
>>>> org.apache.servicemix.mail.cc
>>>> org.apache.servicemix.mail.bcc
>>>> org.apache.servicemix.mail.from
>>>> org.apache.servicemix.mail.replyto
>>>
>>> I don't see any way of removing these properties. Right now I am just
>>> setting these to empty strings. Will that do?
>>>
>>> Sylvester
>>>
>>
>>
>>
>> --
>> http://lhein.blogspot.com
>>
>>
>> -----
>> Regards
>> Lars
>>
>>
>> http://lhein.blogspot.com
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Problem-with-the-Email-binding-component-tp21330046p21429347.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
http://lhein.blogspot.com

Reply via email to