|
Close to what I was doing. All I am doing in the class is configuring the runtime, then using the JMSListener class as my “server” (it uses the thread pool from Doug Lea’s lib to handle incoming requests). You do not actually need to create the service yourself. The Axis runtime will do that for you. It helps to look at the code for JMSListener…it explains a lot. Regardless of whether you use it standalone or inside of an HTTP server, it is basically the same thing happening since the JMSListener and JMSSender classes handle all the transport in and out in either case.
Remember, you have to have a certain directory structure for Axis 2 (which I just copy from the axis2.war), like
config n axis2.xml repository n modules -- modules.listing -- *.mar files n services -- services.listing -- *.aar
So I deploy my actual .aar service file under the /services folder after doing the code generation, modifying the generated code, then using the generated Ant build.xml file to create the .aar and other artifacts. You should also place the standard addressing.mar under modules, and any other modules you are using.
Of course, I am assuming that you have already made the appropriate modifications to your axis2.xml and services.xml (in your .aar) to enable JMS transport. I commented out all of the HTTP-specific configuration in axis2.xml because I did not need it in this case. See the Axis 1.1 docs for JMS transport for a fuller explanation; also see my comments below and in the previous post in the link.
This is a very simple implementation (not sure how it scales on the Axis service side, but a good JMS server setup will scale well on the messaging end). It works well, though, for what we use it for…
public class JMSServer { public static void main(String[] args) { //initialize the Log4J logging—-I just put it in my config folder (you can put it elsewhere…) PropertyConfigurator.configure("./conf/log4j.properties"); try { //The first arg to the method is the root repository location //which contains the /modules and /services subfolders //The second arg is the location of the global config file, axis2.xml ConfigurationContext context = ConfigurationContextFactory .createConfigurationContextFromFileSystem("./repository", "./conf/axis2.xml"); //gets the JMS configuration, as I specified in the previous post TransportInDescription trIn = context.getAxisConfiguration() .getTransportIn(new QName(Constants.TRANSPORT_JMS)); final TransportListener listener = trIn.getReceiver(); //Add a shutdown hook, so that when you stop the java process, it //will shutdown your listener gracefully Runtime.getRuntime().addShutdownHook( new Thread(new Runnable() { public void run() { try { listener.stop(); } catch (AxisFault e) { e.printStackTrace(); } } })); //initialize the listener with the context and transport-in description listener.init(context, trIn); //starts the transport listening for incoming JMS messages listener.start(); } catch (Exception e) { e.printStackTrace(); } } //end main()}
|
Title: Standalone axis
