You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Eric Düll <Er...@innovations.de> on 2006/08/06 18:22:51 UTC

SenSync()

Hi All,

I try to programm a simple JBI-Ping-Pong example...

I allready implemented to JBI Services A and B
A sends sth to B and B prints it out to the console.

As long as I use the send() command, it works. If I
use the SendSync() Command it works also.. but Client A
stops working (and I know why... it is waiting for the
Answer of client B)

My Problem is, I cant figure out, what B has to do to send the
answer back to A...

Client A:

*snip*
      InOut exchange = client.createInOutExchange();
      NormalizedMessage inMessage = exchange.getInMessage();
      inMessage.setProperty("name", "James");
      inMessage.setContent(new StreamSource(new 
StringReader("<hello>world</hello>")));

      exchange.setService(service);
      boolean answer = client.sendSync(exchange);
      NormalizedMessage outMessage = exchange.getOutMessage();
      System.ot.println(outMessage);
*snip*

Client B:

*snip*
         public void run()
         {
            while (process)
            {
               MessageExchange exchange;
               try
               {
                  exchange = channel.accept(5000);
                  if (exchange != null)
                  {
                     if (exchange instanceof InOut)
                     {
                        process((InOut) exchange);
                        ///////////////   What do I have to do implement 
in method process( ) to get a (i.e.) simple String result back to Client 
A? /////////////////////////////////
                     }
                     if (exchange instanceof InOnly)
                     {
                        process((InOnly) exchange);
                     }
                     if (exchange instanceof InOptionalOut)
                     {
                        process((InOptionalOut) exchange);
                     }
                  }
               }
               catch (MessagingException e1)
               {
                  e1.printStackTrace();
               }
               try
               {
                  Thread.sleep(800);
               }
               catch (InterruptedException e)
               {
                  e.printStackTrace();
               }
            }
         }
      });
      t.start();
   }
*snip*


Tanks for your help...

-- 
Eric Düll

Innovations GmbH       http://www.innovations.de
Ziegelei 7             eric.duell@innovations.de
D-88090 Immenstaad     Tel: 0 75 45 / 202-332


Re: SenSync()

Posted by Eric Düll <Er...@innovations.de>.
I looked in the loanbroker Example and in there, 
"MessageExchangeListener" was
used. After a while I got the answer to my problem:

http://www.servicemix.org/site/pojo-support.html?print=1
http://servicemix.org/site/component-helper-classes.html?print=1
http://servicemix.org/site/why-does-servicemix-seems-to-hang-after-some-processing.html
http://servicemix.org/site/writing-lighweight-components.html

now it works..... I think :-)

Eric

Eric Düll schrieb:
> Hi All,
>
> I try to programm a simple JBI-Ping-Pong example...
>
> I allready implemented to JBI Services A and B
> A sends sth to B and B prints it out to the console.
>
> As long as I use the send() command, it works. If I
> use the SendSync() Command it works also.. but Client A
> stops working (and I know why... it is waiting for the
> Answer of client B)
>
> My Problem is, I cant figure out, what B has to do to send the
> answer back to A...
>
> Client A:
>
> *snip*
>      InOut exchange = client.createInOutExchange();
>      NormalizedMessage inMessage = exchange.getInMessage();
>      inMessage.setProperty("name", "James");
>      inMessage.setContent(new StreamSource(new 
> StringReader("<hello>world</hello>")));
>
>      exchange.setService(service);
>      boolean answer = client.sendSync(exchange);
>      NormalizedMessage outMessage = exchange.getOutMessage();
>      System.ot.println(outMessage);
> *snip*
>
> Client B:
>
> *snip*
>         public void run()
>         {
>            while (process)
>            {
>               MessageExchange exchange;
>               try
>               {
>                  exchange = channel.accept(5000);
>                  if (exchange != null)
>                  {
>                     if (exchange instanceof InOut)
>                     {
>                        process((InOut) exchange);
>                        ///////////////   What do I have to do 
> implement in method process( ) to get a (i.e.) simple String result 
> back to Client A? /////////////////////////////////
>                     }
>                     if (exchange instanceof InOnly)
>                     {
>                        process((InOnly) exchange);
>                     }
>                     if (exchange instanceof InOptionalOut)
>                     {
>                        process((InOptionalOut) exchange);
>                     }
>                  }
>               }
>               catch (MessagingException e1)
>               {
>                  e1.printStackTrace();
>               }
>               try
>               {
>                  Thread.sleep(800);
>               }
>               catch (InterruptedException e)
>               {
>                  e.printStackTrace();
>               }
>            }
>         }
>      });
>      t.start();
>   }
> *snip*
>
>
> Tanks for your help...
>

-- 
Eric Düll

Innovations GmbH       http://www.innovations.de
Ziegelei 7             eric.duell@innovations.de
D-88090 Immenstaad     Tel: 0 75 45 / 202-332