Search in sources :

Example 16 with Request

use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.

the class DispatcherImpl method visit.

public void visit(ClientRequest event) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event);
    try {
        dis.reset();
        dis.setBuffer(event.getBuffer());
        Request request = (Request) Dumpalizer.construct(dis, factory);
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", request: " + request);
        request.accept(this);
    } catch (Exception e) {
        e.printStackTrace();
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", exception: " + e);
        ctx.logSwiftlet.logError(ctx.mgmtSwiftlet.getName(), toString() + "/visit, event: " + event + ", exception: " + e);
        valid = false;
    }
}
Also used : Request(com.swiftmq.tools.requestreply.Request)

Example 17 with Request

use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.

the class InboundReader method dataAvailable.

public void dataAvailable(Connection connection, InputStream inputStream) throws IOException {
    dis.setInputStream(inputStream);
    Dumpable obj = Dumpalizer.construct(dis, dumpableFactory);
    if (traceSpace.enabled)
        traceSpace.trace("smqp", "read object: " + obj);
    if (obj.getDumpId() != SMQPFactory.DID_KEEP_ALIVE_REQ) {
        if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
            SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
            for (int i = 0; i < bulkRequest.len; i++) {
                Request req = (Request) bulkRequest.dumpables[i];
                if (req.getDumpId() != SMQPFactory.DID_KEEP_ALIVE_REQ)
                    dispatch(req);
            }
        } else
            dispatch((Request) obj);
    }
}
Also used : SMQPBulkRequest(com.swiftmq.jms.smqp.v500.SMQPBulkRequest) Request(com.swiftmq.tools.requestreply.Request) SMQPBulkRequest(com.swiftmq.jms.smqp.v500.SMQPBulkRequest) Dumpable(com.swiftmq.tools.dump.Dumpable)

Example 18 with Request

use of com.swiftmq.tools.requestreply.Request in project swiftmq-ce by iitsoftware.

the class InboundReader method dataAvailable.

public void dataAvailable(Connection connection, InputStream inputStream) throws IOException {
    dis.setInputStream(inputStream);
    Dumpable obj = Dumpalizer.construct(dis, dumpableFactory);
    if (traceSpace.enabled)
        traceSpace.trace("smqp", "read object: " + obj);
    if (obj.getDumpId() != SMQPFactory.DID_KEEP_ALIVE_REQ) {
        if (obj.getDumpId() == SMQPFactory.DID_BULK_REQ) {
            SMQPBulkRequest bulkRequest = (SMQPBulkRequest) obj;
            for (int i = 0; i < bulkRequest.len; i++) {
                Request req = (Request) bulkRequest.dumpables[i];
                if (req.getDumpId() != SMQPFactory.DID_KEEP_ALIVE_REQ)
                    dispatch(req);
            }
        } else
            dispatch((Request) obj);
    }
}
Also used : SMQPBulkRequest(com.swiftmq.jms.smqp.v400.SMQPBulkRequest) Request(com.swiftmq.tools.requestreply.Request) SMQPBulkRequest(com.swiftmq.jms.smqp.v400.SMQPBulkRequest) Dumpable(com.swiftmq.tools.dump.Dumpable)

Example 19 with Request

use of com.swiftmq.tools.requestreply.Request in project swiftmq-client by iitsoftware.

the class XAResourceImpl method prepare.

public synchronized int prepare(Xid xid) throws XAException {
    if (logWriter != null)
        log(toString() + "/prepare, xid=" + xid);
    XidImpl sxid = toSwiftMQXid(xid);
    XAResPrepareReply reply = null;
    try {
        int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
        Request request = new XAResPrepareRequest(this, session.getDispatchId(), sxid, false, endRequestInDoubt() ? XARecoverRegistry.getInstance().getRequestList(sxid) : null);
        request.setConnectionId(connectionId);
        reply = (XAResPrepareReply) session.request(request);
    } catch (Exception e) {
        XAException ex = new XAException(e.toString());
        ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    }
    if (!reply.isOk()) {
        XAException ex = new XAException(reply.getException().getMessage());
        if (reply.getErrorCode() != 0)
            ex.errorCode = reply.getErrorCode();
        else
            ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    }
    XARecoverRegistry.getInstance().clear(sxid);
    return XA_OK;
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

Example 20 with Request

use of com.swiftmq.tools.requestreply.Request in project swiftmq-client by iitsoftware.

the class XAResourceImpl method rollback.

public synchronized void rollback(Xid xid) throws XAException {
    if (logWriter != null)
        log(toString() + "/rollback, xid=" + xid);
    XidImpl sxid = toSwiftMQXid(xid);
    xidMapping.remove(xid);
    XAResRollbackReply reply = null;
    try {
        int connectionId = session.getSessionImpl().getMyConnection().getConnectionId();
        session.getSessionImpl().startRecoverConsumers();
        session.getAndClearCurrentTransaction();
        List recoveryList = null;
        if (endRequestInDoubt())
            recoveryList = XARecoverRegistry.getInstance().getRequestList(sxid);
        Request request = new XAResRollbackRequest(this, session.getDispatchId(), sxid, false, recoveryList, session.getSessionImpl().getRecoveryEpoche());
        request.setConnectionId(connectionId);
        reply = (XAResRollbackReply) session.request(request);
    } catch (Exception e) {
        if (completionListener != null)
            completionListener.transactionAborted(sxid);
        XAException ex = new XAException(e.toString());
        ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    }
    if (reply.isOk()) {
        session.getSessionImpl().endRecoverConsumersXA();
        try {
            session.getSessionImpl().closeDelayedProducers();
        } catch (JMSException e) {
            e.printStackTrace();
        }
        if (completionListener != null)
            completionListener.transactionAborted(sxid);
        XARecoverRegistry.getInstance().clear(sxid);
    } else {
        if (completionListener != null)
            completionListener.transactionAborted(sxid);
        XAException ex = new XAException(reply.getException().getMessage());
        if (reply.getErrorCode() != 0)
            ex.errorCode = reply.getErrorCode();
        else
            ex.errorCode = XAException.XAER_RMFAIL;
        throw ex;
    }
}
Also used : XAException(javax.transaction.xa.XAException) XidImpl(com.swiftmq.jms.XidImpl) Request(com.swiftmq.tools.requestreply.Request) List(java.util.List) JMSException(javax.jms.JMSException) ValidationException(com.swiftmq.tools.requestreply.ValidationException) JMSException(javax.jms.JMSException) XAException(javax.transaction.xa.XAException)

Aggregations

Request (com.swiftmq.tools.requestreply.Request)35 XidImpl (com.swiftmq.jms.XidImpl)16 JMSException (javax.jms.JMSException)16 ValidationException (com.swiftmq.tools.requestreply.ValidationException)14 XAException (javax.transaction.xa.XAException)14 Dumpable (com.swiftmq.tools.dump.Dumpable)8 RequestHandler (com.swiftmq.impl.routing.single.smqpr.RequestHandler)6 StartStageRequest (com.swiftmq.impl.routing.single.smqpr.StartStageRequest)6 List (java.util.List)6 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)4 ChallengeResponseFactory (com.swiftmq.auth.ChallengeResponseFactory)2 POAddObject (com.swiftmq.impl.routing.single.manager.po.POAddObject)2 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest)2 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v942.ConnectReplyRequest)2 MessageImpl (com.swiftmq.jms.MessageImpl)2 QueuePullTransaction (com.swiftmq.swiftlet.queue.QueuePullTransaction)2 QueueReceiver (com.swiftmq.swiftlet.queue.QueueReceiver)2 TimerListener (com.swiftmq.swiftlet.timer.event.TimerListener)2 XAContext (com.swiftmq.swiftlet.xa.XAContext)2 XidFilter (com.swiftmq.swiftlet.xa.XidFilter)2