Let us now run the Chapter6
sample application that demonstrates the usage of the JBR gateway:
jboss-esb.xml
file in Source mode.provider
to the providers
list:<jbr-provider name="JBRprovider" protocol="htp" host="localhost"> <property name="serviceInvokerTimeout" value="20000"/> <jbr-bus busid="chapter6JBRChannel" port="9888"/> </jbr-provider>
listener
definition to the <listeners>
tag.<listeners> <jms-listener busidref="chapter6ESBChannel" name="Chapter6ESBListener"/> <jms-listener busidref="chapter6GwChannel" is-gateway="true" name="Chapter6GwListener"/> <jbr-listener busidref="chapter6JBRChannel" name="Chapter6JBRGwListener" is-gateway="true"/> </listeners>
src
folder and expand it till the SendJBRMessage.java
file is displayed in the tree. Now click Run | Run As | Java Application.JBoss Remoting Gateway says Hello!
We sent a message via the JBR gateway listener and we received the response synchronously. Here is the listing of the client code for reference:
public static void main(String[] args) throws Exception { String serverURL = "http://localhost:9888"; HttpURLConnection connection =(HttpURLConnection)new URL(serverURL).openConnection(); connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); PrintWriter out = new PrintWriter(new OutputStreamWriter(connection.getOutputStream())); out.println("Hello JBoss Remoting Gateway!"); out.close(); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } in.close(); }