Hi Sadik; In the current code base we done a major improvements in our transport freamwork with the introduction of ListenerManager. So in the next release onword you wont have such a problem.
Ali Sadik Kumlali wrote: > Dear all, > > I simply changed EchoNonBlockingDualClient sample to make it run as > threads and created two threads. First one successfully starts > SimpleHTTPServer on port 6060 and the second one gets an > "java.net.BindException: Address already in use: JVM_Bind" while > trying to start the server. > > Doesn't I have an option to listen all the responses for its dedicated > port? For example 6060 for first request, 6061 for the second, and so > on. Or, should i assume Axis2 to use the same port for the responses > of all the long running transactions? > > Thanks a lot for any help. > > Ali Sadik Kumlali > > -------------------------------------------------------------------------------------------------- > Error Message I Get > -------------------------------------------------------------------------------------------------- > testEchoNonBlockingDualClient: > [java] [CLIENT1] Outgoing message > [java] <example1:ec ho > xmlns:example1="http://example1.org/example1"><exampl > e1:Text>Axis2 Echo String </example1:Text></example1:echo> > [java] - Deploying module : addressing > [java] [CLIENT2] Outgoing message > [java] <example1:echo > xmlns:example1="http://example1.org/example1"><exampl > e1:Text>Axis2 Echo String </example1:Text></example1:echo> > [java] - Deploying module : addressing > [java] - java.net.BindException: Address already in use: JVM_Bind > [java] org.apache.axis2.AxisFault: Address already in use: > JVM_Bind; nested > exception is: > [java] java.net.BindException: Address already in use: JVM_Bind > [java] at > org.apache.axis2.transport.http.SimpleHTTPServer.start(Simple > HTTPServer.java:220) > [java] at > org.apache.axis2.client.ListenerManager.makeSureStarted(Liste > nerManager.java:73) > > > -------------------------------------------------------------------------------------------------- > Modified EchoNonBlockingDualClient.java > -------------------------------------------------------------------------------------------------- > public class EchoNonBlockingDualClient implements Runnable { > private static EndpointReference targetEPR = new EndpointReference( > "http://127.0.0.1:8080/axis2/services/MyService"); > > private String name; > > public EchoNonBlockingDualClient(String name) { > this.name = name; > } > > publ ic OMElement getPayload() throws XMLStreamException, > FactoryConfigurationError { > OMElement payload = ClientUtil.getEchoOMElement(); > > // Log the outgoing payload > StringWriter writer = new StringWriter(); > > payload.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter( > writer)); > writer.flush(); > System.out.println("[" + name + "] Outgoing message\n" > + writer.toString()); > return payload; > } > > public Options getOptions() { > & nbsp; Options options = new Options(); > options.setTo(targetEPR); > options.setTransportInProtocol(Constants.TRANSPORT_HTTP); > options.setUseSeparateListener(true); > return options; > } > > public void makeRequest() { > try { > OMElement payload = getPayload(); > Options options = getOptions(); > > // Callback to handle the response > Callback callback = new Callback() { > public void onComplete(AsyncResult result) { > try { > StringWriter writer = new StringWriter(); > result.getResponseEnvelope().serialize( > XMLOutputFactory.newInstance() > .createXMLStreamWriter(writer)); > writer.flush(); > System.out.println("[" + name + "] Incoming > message\n" > + writer.toString()); > try { > Thread.sleep(1000); > } catch (InterruptedException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > } catch (XMLStreamException e) { > onError(e); > } > } > > public void onError(Exception e) { > e.printStackTrace(); > } > }; > > // Non-Blocking Invocation > ServiceClient sender = new ServiceClient(); > sender.setOptions(options); > sender.sendReceiveNonblocking(payload, callback); > > // Wait till the callback receives the response. > while (!callback.isComplete()) { > System.out.println("[" + name > + "] I'm waiting for the response from the > server"); > Thread.sleep(1000); > } > // Need to close the Client Side Listener. > > } catch (AxisFault axisFault) { > axisFault.printStackTrace(); > } catch (Exception ex) { > ex.printStackTrace(); > } > } > > public void run() { > makeRequest(); > } > > private static final void wait(int ms) { > try { > Thread.sleep(ms); > } catch (InterruptedException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > > public static void main(String[] args) { > Thread client1 = new Thread(new > EchoNonBlockingDualClient("CLIENT1")); > client1.start(); > > wait(1000); > > Thread client2 = new Thread(new > EchoNonBlockingDualClient("CLIENT2")); > client2.start(); > } > > } > > ------------------------------------------------------------------------ > Yahoo! Mail > Bring photos to life! New PhotoMail > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=39174/*http://photomail.mail.yahoo.com> > makes sharing a breeze. > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > -- Thanks, Deepal ................................................................ ~Future is Open~
