Deploying jPOS in jboss or Start jPOS Q2 in jboss. That is start jPOS server as an Internal feature of jboss application server (now wildfly)
1 Answers
Step by Step Process to start jpos Q2 in jboss
Create a .sar file named q2mbean-1.0.sar to start the Queue.
Place the created .sar file in the .ear file (jposQ.ear).
Thus the path now is jposQ.ear/Q2mbean-1.0.sar.
Place the .ear file in the deploy directory of jboss.
SAR CREATION:
The Created .sar file should contain the class file named Q2Service.class Thus the Q2Service.class file should be in the directory given below q2mbean-1.0.sar\org\jpos\mbean. The Q2Service.java is
> package org.jpos.mbean; > > import javax.management.*; import org.jboss.logging.Logger; import > org.jboss.system.ServiceMBeanSupport; import org.jpos.q2.Q2; > > // Referenced classes of package org.jpos.mbean: // > Q2ServiceMBean > > public class Q2Service extends ServiceMBeanSupport implements > Q2ServiceMBean, Runnable { > > public Q2Service() > { > q2Server = null; > } > > protected void startService() > throws Exception > { > super.startService(); > super.log.info("Q2Service starting"); > String deployPath[] = { > "-d", "q2/deploy" > }; > q2Server = new Q2(deployPath); > (new Thread(this)).start(); > } > > public void run() > { > try > { > q2Server.start(); > } > catch(MalformedObjectNameException e) { e.printStackTrace(); } > catch(InstanceAlreadyExistsException e) { e.printStackTrace(); } > catch(NotCompliantMBeanException e) { e.printStackTrace(); } > catch(MBeanRegistrationException e) { e.printStackTrace(); } > } > protected void stopService() > throws Exception > { > super.stopService(); > super.log.info("Q2Service stopping"); > q2Server.shutdown(); > } > private Q2 q2Server; }
The .sar file also have an interface named Q2ServiceMBean.class. Q2ServiceMBean.java is
package org.jpos.mbean;
import org.jboss.system.ServiceMBean;
public interface Q2ServiceMBean extends ServiceMBean
{
}
The xml file named (jboss-service.xml) should be created in the directory q2mbean-1.0.sar\META-INF\ jboss-service.xml.
The xml says the class path to the sar :
<?xml version="1.0" encoding="UTF-8" ?>
<service>
<mbean code="org.jpos.mbean.Q2Service" name="Q2:name=Q2Service">
</mbean>
</service>
EAR CREATION:
Your Ear should begin with an xml file named application.xml which should be in jposQ.ear\META-INF\application.xml
In the same way another xml file should be created which is jboss-app.xml in the jposQ.ear\META-INF\jboss-app.xml
application.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4">
<display-name>JBossAtWorkEAR</display-name>
<module>
<java>jpos.jar</java>
</module>
</application>
jboss-app.xml
<?xml version="1.0" encoding="UTF-8" ?>
<jboss-app>
<loader-repository>myapp:archive=jposQ.ear</loader-repository>
<module>
<service>q2mbean-1.0.sar</service>
</module>
</jboss-app>
Then the Ear file should have the following files q2mbean-1.0.sar, jpos.jar include the lib dir from jpos to the ear. Place the deploy folder from jpos in jboss-x.x.x/bin/q2/deploy Place the log folder and file in jboss-x.x.x/bin/log
Find the sar file here : http://jpos.org/download/q2mbean-1.0.sar

- 752
- 1
- 6
- 10