Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to delay lookups #903

wants to merge 1 commit into from
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -59,25 +59,20 @@
public class ProtocolConverter {
private static final transient Log log = LogFactory.getLog(ProtocolConverter.class);
private final TcpTransport tcpTransport;
private ConnectionFactory noneXAConnectionFactory;
private XAConnectionFactory xaConnectionFactory;
private StompSession noneXaSession;
private Map<Xid, StompSession> xaSessions = new ConcurrentHashMap<Xid, StompSession>();

private TransactionManager tm;
private String login;
private String passcode;
private String clientId;
private InitialContext initialContext;
private boolean closed;
private StompConnect stompConnect;

public ProtocolConverter(InitialContext initialContext, ConnectionFactory connectionFactory,
XAConnectionFactory xaConnectionFactory, TcpTransport outputHandler) throws NamingException {
this.noneXAConnectionFactory = connectionFactory;
this.xaConnectionFactory = xaConnectionFactory;
this.tcpTransport = outputHandler;
public ProtocolConverter(InitialContext initialContext, StompConnect stompConnect, TcpTransport outputHandler) throws NamingException {
this.initialContext = initialContext;
tm = (TransactionManager) initialContext.lookup("java:/TransactionManager");
this.stompConnect = stompConnect;
this.tcpTransport = outputHandler;

@@ -177,7 +172,7 @@ public void onStompFrame(StompFrame command) throws IOException {

// Implemenation methods
// -------------------------------------------------------------------------
protected void onStompConnect(StompFrame command) throws IOException, JMSException {
protected void onStompConnect(StompFrame command) throws IOException, JMSException, NamingException {
if (noneXaSession != null) {
throw new ProtocolException("Already connected.");
@@ -189,9 +184,9 @@ protected void onStompConnect(StompFrame command) throws IOException, JMSExcepti

Connection noneXaConnection;
if (login != null) {
noneXaConnection = noneXAConnectionFactory.createConnection(login, passcode);
noneXaConnection = stompConnect.getConnectionFactory().createConnection(login, passcode);
} else {
noneXaConnection = noneXAConnectionFactory.createConnection();
noneXaConnection = stompConnect.getConnectionFactory().createConnection();
if (clientId != null) {
@@ -389,15 +384,15 @@ protected String createSubscriptionId(Map<String, Object> headers) {
return "/subscription-to/" + headers.get(Stomp.Headers.Subscribe.DESTINATION);

protected StompSession getXASession(Xid xid) throws JMSException {
protected StompSession getXASession(Xid xid) throws JMSException, NamingException {
StompSession xaSession = xaSessions.get(xid);
if (xaSession == null) {

XAConnection xaConnection;
if (login != null) {
xaConnection = xaConnectionFactory.createXAConnection(login, passcode);
xaConnection = stompConnect.getXAConnectionFactory().createXAConnection(login, passcode);
} else {
xaConnection = xaConnectionFactory.createXAConnection();
xaConnection = stompConnect.getXAConnectionFactory().createXAConnection();
if (clientId != null) {
@@ -57,15 +57,7 @@ public StompConnect() throws NamingException {

public void assignProtocolConverter(TcpTransport transport) throws NamingException {
ConnectionFactory factory = getConnectionFactory();
if (factory == null) {
throw new IllegalArgumentException("No ConnectionFactory is configured!");
XAConnectionFactory xaFactory = getXAConnectionFactory();
if (xaFactory == null) {
throw new IllegalArgumentException("No XAConnectionFactory is configured!");
new ProtocolConverter(initialContext, factory, xaFactory, transport);
new ProtocolConverter(initialContext, this, transport);

// Properties
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.