Sorry I can't attach I paste it:

public class SimpleComponent3 extends ComponentSupport implements 
MessageExchangeListener {

        private final static Logger logger = 
Logger.getLogger(SimpleComponent3.class);
                @Resource
            DeliveryChannel channel;


    public void onMessageExchange(MessageExchange exchange) throws 
MessagingException {


                NormalizedMessage message = getInMessage(exchange);
        String stringMsg = null;
                String orch = null;
                boolean invia= false;
                int orchNum=0;
        SourceTransformer sourceTransformer = new SourceTransformer();
        synchronized(this){
        try {
                  stringMsg = sourceTransformer.toString(message.getContent());
                          StringTokenizer stk = new 
StringTokenizer(stringMsg,":,-");
                                      orch = stk.nextToken();
                  logger.info("O3 received payload " + stringMsg);
                  if(orch.equals("S")){
                        stringMsg = "O:3-" + stringMsg;
                        logger.info("O3 received payload " + stringMsg);
                        invia = true;
                        }
                        String orchNumS = stk.nextToken();
                    orchNum = Integer.parseInt(orchNumS);

        } catch(TransformerException e) {
                logger.error("error while reading payload", e);
        }

        exchange.setStatus(ExchangeStatus.DONE);

        channel.send(exchange);


        if(invia){
                ServiceMixClient client = createClient();

                Destination destination = client.createDestination(
                                
"service:http://myproject.com/components/ServizioProvider";);
        InOnly inOnlyExchange = destination.createInOnlyExchange();
        NormalizedMessage inMessage = inOnlyExchange.getInMessage();
        inMessage.setContent(new StringSource(stringMsg));
        invia= false;
        logger.info("3 INVIA!");
               client.send(inOnlyExchange);
        }
         }
    }
    private ServiceMixClient createClient() {
                try {
                        ClientFactory factory = (ClientFactory) new 
InitialContext().lookup(ClientFactory.DEFAULT_JNDI_NAME);
                        return factory.createClient();
                } catch(Exception e) {
                        e.printStackTrace();
                        return null;
                }
        }
}

---------- Initial Header -----------

>From      : "silvia_magrelli" [email protected]
To          : "users" [email protected]
Cc          :
Date      : Sat, 27 Dec 2008 01:28:47 +0100
Subject : Re: onMessageExchange problems







> Dear all,
> thank you very much for your answers.
> I had temporarily solved the question using an eip configuration. Now that I 
> tried again to use a topic the problem arise again.
> Would you kindly help me because I can't understand where the problem is?
>
> I'll send the code so you can see and tell me where I did wrong... and I 
> remind in few words what I'm trying to do:
>
> -there are four POJO:
> SimpleComponent1, SimpleComponent2, SimpleComponent3,
> SimpleComponent4,( they are identical except for name and
> some prints)
> -each POJO first receive a message from an external queue each
>  (simple.input1, simple.input2, simple.input3, simple.input4)
> -after they have received that message, they send it to the other 3 POJOs and 
> to itself.
>
> I undestood that there is a thread for every message received
> and that I have to use thread-safe code but
> even if I put in a synchronized block all the content
> of the method OnMessageExchange, some messages get lost.
>
> I wonder that I' ve made some configuration error,
> so I'll send configuration file too.
>
> The configuration have a jms provider to which the POJOs send
> messages, this jms porvider write to a topic
> and there are four jms consumer that listens to this topic
> and deliver message to its correspondig POJOs
>
> I'd very grateful if someone can spent few minutes and explain how to make 
> the things works or at least where
> is the error and what I did not understand well.
> Thank you in advance,
> sorry if I haven't look at the right documents.
> Best regards
>
> silvia
>
>
>
>
>
> ---------- Initial Header -----------
>
> From      : "Gert Vanthienen" [email protected]
> To          : [email protected]
> Cc          :
> Date      : Tue, 16 Dec 2008 09:21:44 +0100
> Subject : Re: onMessageExchange problems
>
>
>
>
>
>
>
> > Silvia,
> >
> > The servicemix-bean component uses a thread pool to handle multiple
> > messages concurrently.  There's not really anything special you need to
> > do, but you should however take care to write your onMessageExchange 
> > method in a thread-safe way.  Btw, I guess you're using a JMS and Bean
> > SU, right?
> >
> > If you have any more problems with this, could you post the code from
> > you servicemix-bean component.  Another possibility to troubleshoot this
> > is by enabling DEBUG logging and looking at the MessageExchanges (more
> > particularly at the MEP and the status code) to figure out where
> > messages get lost.
> >
> > Regards,
> >
> > Gert
> >
> > silvia_magrelli wrote:
> > > Hi,
> > > I have implemented my publish\subscribe with bcs and bean ses
> > > and 1 topic. I have to realize many to many comunication.
> > > If I realize one to many comunication (1 publisher and 3 subscribers(one 
> > > of the subscriber is the publisher itself)) all works well.
> > > Instead if I use many to many with all the three component that
> > > i have are publisher and subscriber at the same time then some
> > > message get lost.
> > > I wonder that the reason is that the call to onMessageExchange in my bean 
> > > that found it busy doesn't
> > > retry for a second time, there isn't buffering of
> > > such method's invocations or there isn't a new thread that
> > > treat the message receiving.
> > > Did I understand well?
> > > What methods and classes should I have to use in servicemix
> > > to not loose messages and treat them all in my java-bean components ?
> > > (I'm using servicemix 3.2.1)
> > > Please help me!
> > > Thank You in advance for your help!
> > > greetings,
> > > silvia
> > >
> > >
> > >
> >
> >
>
>
>



Reply via email to