[Quickfix-developers] Using quickfix in jboss
Brought to you by:
orenmnero
From: Brad H. <Bra...@gb...> - 2004-10-07 02:16:26
|
Hi All, I am investigating using quickfix in a jmx mbean in jboss and have run into some troubles. Has anyone had any success running it in an appserver before? At present I am able to run my code as a standard java app (a junit test in eclipse, to be precise) and it seems to work ok - it connects to the executor sample application and exchanges logon/logoff messages. However, when I fire it up within jboss I run into some troubles. The loadLibrary call completes ok, and I am able to make calls through the jni layer. For example, I can get configuration exceptions back, and I can get Session created log messages. Unfortunately, as soon as the Connection succeeded log is written I get a dialog pop up: Microsoft Visual C++ Runtime Library Runtime Error! Program c:\j2sdk1.4.2\bin\java.exe abnormal program termination When I hit ok on the dialog jboss ends (but it actually continues to run until I hit ok). What is especially strange is that it doesn't do a stack dump (like it does when you get a Unexpected Signal : EXCEPTION_ACCESS_VIOLATION) - the java process just dies. I am using: windows xp quickfix 1.9.2 vc7 binary jboss 3.2.5 I have also tried with the vc6 binary. This just terminates jboss immediately with an abnormal termination error message. I also tried with quickfix 1.8 and got the same error. I have tried as both initiator and acceptor and get the same problem both ways. =20 Here's some sample log messages. The first set were from the unit test, the second are from the appserver. 20041006-22:57:35 : Created session 20041006-22:57:37 : Connecting to 127.0.0.1 on port 65001 20041006-22:57:37 : Connection succeeded 20041006-22:57:38 : Initiated logon request 20041006-22:57:38 : Received logon response 20041006-22:57:38 : Received ResendRequest FROM: 13 TO: 0 20041006-22:57:38 : Sent SequenceReset TO: 15 20041006-22:58:27 : Initiated logout request 20041006-22:58:27 : Received logout response 20041006-22:58:27 : Disconnecting 20041006-22:58:55 : Created session 20041006-22:58:55 : Connecting to 127.0.0.1 on port 65001 20041006-22:58:55 : Connection succeeded (crashes now) Any hints on what I might be doing wrong (or why I should avoid the whole concept) would be appreciated. I've included the code and settings below. It's pretty close to the samples given in the documentation, with some extra stuff to make it an mbean (the interface). Thanks, Brad. # default settings for sessions [DEFAULT] ConnectionType=3Dinitiator ReconnectInterval=3D60 SenderCompID=3DTW FileStorePath=3DD:\tmp\fixstore FileLogPath=3DD:\tmp\fixstore # session definition [SESSION] # inherit ConnectionType, ReconnectInterval and SenderCompID from default BeginString=3DFIX.4.2 TargetCompID=3DARCA StartTime=3D00:00:00 EndTime=3D23:59:59 HeartBtInt=3D20 SocketConnectPort=3D65001 SocketConnectHost=3D127.0.0.1 DataDictionary=3DD:\downloads\quickfix\spec\FIX42.xml /* * Two files, HelloWorld.java (which implements the MBean) and HelloWorldMBean.java which defines it. * I compile these, jar them and stick them in the jboss deploy directory. * The quickfix.jar also lives in there, but quickfix_jni.dll is in the $JBOSS_HOME/bin directory. * * The deployment descriptor is fairly simple, just specifies that HelloWorld.jar and quickfix.jar are on the classpath * and sets the helloMessage string to the name of the settings file and sets acceptor to true or false. * * The MBean deploys fine, but when I invoke startSessions() and a connection is established it crashes :( */ /* HelloWorld.java */ package com.test.mbean; import java.io.FileInputStream; import quickfix.Acceptor; import quickfix.Application; import quickfix.DefaultMessageFactory; import quickfix.DoNotSend; import quickfix.FieldNotFound; import quickfix.FileLogFactory; import quickfix.FileStoreFactory; import quickfix.IncorrectDataFormat; import quickfix.IncorrectTagValue; import quickfix.Initiator; import quickfix.LogFactory; import quickfix.Message; import quickfix.MessageFactory; import quickfix.MessageStoreFactory; import quickfix.RejectLogon; import quickfix.SessionID; import quickfix.SessionSettings; import quickfix.SocketAcceptor; import quickfix.SocketInitiator; import quickfix.UnsupportedMessageType; public class HelloWorld implements HelloWorldMBean, Application { =20 /* should really rename this var, left over from my hello world mbean.... */ private String helloMessage =3D "d:\tmp\session.ini"; private boolean isAcceptor =3D true; private Acceptor acceptor; private Initiator initiator; static { System.loadLibrary("quickfix_jni"); } /** * @return Returns the helloMessage. */ public String getHelloMessage() { return helloMessage; } /** * @param helloMessage The helloMessage to set. */ public void setHelloMessage(String helloMessage) { this.helloMessage =3D helloMessage; } public String startSession() { try { SessionSettings settings =3D new SessionSettings(new =20 FileInputStream(helloMessage)); MessageStoreFactory storeFactory =3D new FileStoreFactory(settings); LogFactory logFactory =3D new FileLogFactory(settings); MessageFactory messageFactory =3D new DefaultMessageFactory(); if (isAcceptor) { acceptor =3D new SocketAcceptor (this, storeFactory, settings, logFactory, =20 messageFactory); acceptor.start(); } else { initiator =3D new SocketInitiator (this, storeFactory, settings, logFactory, =20 messageFactory); initiator.start(); System.out.println("Initiator started"); } return getHelloMessage(); } catch (Exception e) { return "ERROR: " + e.getMessage(); } } public void stopSession() { if (acceptor !=3D null) { acceptor.stop(); } if (initiator !=3D null) { initiator.stop(); } } /** * @return Returns the acceptor. */ public boolean isAcceptor() { return isAcceptor; } /** * @param acceptor The acceptor to set. */ public void setAcceptor(boolean acceptor) { this.isAcceptor =3D acceptor; } /* auto generated methods for application */ /* (non-Javadoc) * @see quickfix.Application#onCreate(quickfix.SessionID) */ public void onCreate(SessionID arg0) { System.out.println("Session created: " + arg0); } /* (non-Javadoc) * @see quickfix.Application#onLogon(quickfix.SessionID) */ public void onLogon(SessionID arg0) { System.out.println("Logon: " + arg0); } /* (non-Javadoc) * @see quickfix.Application#onLogout(quickfix.SessionID) */ public void onLogout(SessionID arg0) { // TODO Auto-generated method stub } /* (non-Javadoc) * @see quickfix.Application#toAdmin(quickfix.Message, =20 quickfix.SessionID) */ public void toAdmin(Message arg0, SessionID arg1) { // TODO Auto-generated method stub } /* (non-Javadoc) * @see quickfix.Application#toApp(quickfix.Message, =20 quickfix.SessionID) */ public void toApp(Message arg0, SessionID arg1) throws DoNotSend { // TODO Auto-generated method stub } /* (non-Javadoc) * @see quickfix.Application#fromAdmin(quickfix.Message, =20 quickfix.SessionID) */ public void fromAdmin(Message arg0, SessionID arg1) throws =20 FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon { // TODO Auto-generated method stub } /* (non-Javadoc) * @see quickfix.Application#fromApp(quickfix.Message, =20 quickfix.SessionID) */ public void fromApp(Message arg0, SessionID arg1) throws =20 FieldNotFound, IncorrectDataFormat, IncorrectTagValue, =20 UnsupportedMessageType { // TODO Auto-generated method stub } } /* HelloWorldMBean.java */ /* * The MBean interface declaration defines what * methods are availble to the mbean server */ package com.test.mbean; public interface HelloWorldMBean { public void setHelloMessage(String helloMessage); public String getHelloMessage(); public void setAcceptor(boolean acceptor); public boolean isAcceptor(); public String startSession(); public void stopSession(); } |