Search in sources :

Example 6 with CloseProducerRequest

use of com.swiftmq.jms.smqp.v400.CloseProducerRequest in project swiftmq-client by iitsoftware.

the class MessageProducerImpl method validate.

public void validate(Request request) throws ValidationException {
    if (request instanceof ProduceMessageRequest) {
        try {
            ProduceMessageRequest r = (ProduceMessageRequest) request;
            r.setDispatchId(mySession.dispatchId);
            r.setQueueProducerId(producerId);
            MessageImpl msg = SMQPUtil.getMessage(r);
            Destination dest = msg.getJMSDestination();
            // failover
            if (dest instanceof TemporaryQueue || dest instanceof TemporaryTopic) {
                r.setCancelledByValidator(true);
                return;
            }
            msg.setBooleanProperty(MessageImpl.PROP_DOUBT_DUPLICATE, true);
            if (r.getSingleMessage() != null)
                r.setSingleMessage(msg);
            else
                r.setMessageCopy(SMQPUtil.toBytes(msg));
        } catch (Exception e) {
            e.printStackTrace();
            throw new ValidationException(e.toString());
        }
    } else {
        CloseProducerRequest r = (CloseProducerRequest) request;
        r.setDispatchId(mySession.dispatchId);
        r.setQueueProducerId(producerId);
    }
}
Also used : ProduceMessageRequest(com.swiftmq.jms.smqp.v630.ProduceMessageRequest) CloseProducerRequest(com.swiftmq.jms.smqp.v630.CloseProducerRequest)

Example 7 with CloseProducerRequest

use of com.swiftmq.jms.smqp.v400.CloseProducerRequest in project swiftmq-client by iitsoftware.

the class MessageProducerImpl method _close.

void _close(boolean delayClose) throws JMSException {
    if (closed || mySession.isClosed())
        return;
    if (delayClose) {
        if (mySession.transacted) {
            mySession.delayClose(this);
            return;
        }
    }
    closed = true;
    // Fix: 2.1.0
    if (producerId == -1)
        return;
    Reply reply = null;
    try {
        reply = requestRegistry.request(new CloseProducerRequest(this, mySession.dispatchId, producerId));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (!reply.isOk()) {
        throw ExceptionConverter.convert(reply.getException());
    }
    mySession.removeMessageProducerImpl(this);
}
Also used : ProduceMessageReply(com.swiftmq.jms.smqp.v630.ProduceMessageReply) CloseProducerRequest(com.swiftmq.jms.smqp.v630.CloseProducerRequest)

Example 8 with CloseProducerRequest

use of com.swiftmq.jms.smqp.v400.CloseProducerRequest in project swiftmq-client by iitsoftware.

the class MessageProducerImpl method close.

/**
 * Since a provider may allocate some resources on behalf of a
 * MessageProducer outside the JVM, clients should close them when they
 * are not needed. Relying on garbage collection to eventually reclaim
 * these resources may not be timely enough.
 */
public void close() throws JMSException {
    if (closed || mySession.isClosed())
        return;
    closed = true;
    // Fix: 2.1.0
    if (producerId == -1)
        return;
    Reply reply = null;
    try {
        reply = requestRegistry.request(new CloseProducerRequest(dispatchId, producerId));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (!reply.isOk()) {
        throw ExceptionConverter.convert(reply.getException());
    }
}
Also used : ProduceMessageReply(com.swiftmq.jms.smqp.v400.ProduceMessageReply) Reply(com.swiftmq.tools.requestreply.Reply) CloseProducerRequest(com.swiftmq.jms.smqp.v400.CloseProducerRequest)

Example 9 with CloseProducerRequest

use of com.swiftmq.jms.smqp.v400.CloseProducerRequest in project swiftmq-client by iitsoftware.

the class MessageProducerImpl method _close.

void _close(boolean delayClose) throws JMSException {
    if (closed || mySession.isClosed())
        return;
    if (delayClose) {
        if (mySession.transacted) {
            mySession.delayClose(this);
            return;
        }
    }
    closed = true;
    // Fix: 2.1.0
    if (producerId == -1)
        return;
    Reply reply = null;
    try {
        reply = requestRegistry.request(new CloseProducerRequest(this, mySession.dispatchId, producerId));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (!reply.isOk()) {
        throw ExceptionConverter.convert(reply.getException());
    }
    mySession.removeMessageProducerImpl(this);
}
Also used : ProduceMessageReply(com.swiftmq.jms.smqp.v610.ProduceMessageReply) CloseProducerRequest(com.swiftmq.jms.smqp.v610.CloseProducerRequest)

Example 10 with CloseProducerRequest

use of com.swiftmq.jms.smqp.v400.CloseProducerRequest in project swiftmq-client by iitsoftware.

the class MessageProducerImpl method validate.

public void validate(Request request) throws ValidationException {
    if (request instanceof ProduceMessageRequest) {
        try {
            ProduceMessageRequest r = (ProduceMessageRequest) request;
            r.setDispatchId(mySession.dispatchId);
            r.setQueueProducerId(producerId);
            MessageImpl msg = SMQPUtil.getMessage(r);
            Destination dest = msg.getJMSDestination();
            // failover
            if (dest instanceof TemporaryQueue || dest instanceof TemporaryTopic) {
                r.setCancelledByValidator(true);
                return;
            }
            msg.setBooleanProperty(MessageImpl.PROP_DOUBT_DUPLICATE, true);
            if (r.getSingleMessage() != null)
                r.setSingleMessage(msg);
            else
                r.setMessageCopy(SMQPUtil.toBytes(msg));
        } catch (Exception e) {
            e.printStackTrace();
            throw new ValidationException(e.toString());
        }
    } else {
        CloseProducerRequest r = (CloseProducerRequest) request;
        r.setDispatchId(mySession.dispatchId);
        r.setQueueProducerId(producerId);
    }
}
Also used : ProduceMessageRequest(com.swiftmq.jms.smqp.v610.ProduceMessageRequest) CloseProducerRequest(com.swiftmq.jms.smqp.v610.CloseProducerRequest)

Aggregations

Reply (com.swiftmq.tools.requestreply.Reply)3 CloseProducerRequest (com.swiftmq.jms.smqp.v600.CloseProducerRequest)2 CloseProducerRequest (com.swiftmq.jms.smqp.v610.CloseProducerRequest)2 CloseProducerRequest (com.swiftmq.jms.smqp.v630.CloseProducerRequest)2 CloseProducerRequest (com.swiftmq.jms.smqp.v750.CloseProducerRequest)2 IllegalStateException (javax.jms.IllegalStateException)2 CloseProducerRequest (com.swiftmq.jms.smqp.v400.CloseProducerRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v400.ProduceMessageReply)1 CloseProducerRequest (com.swiftmq.jms.smqp.v500.CloseProducerRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v500.ProduceMessageReply)1 CloseProducerRequest (com.swiftmq.jms.smqp.v510.CloseProducerRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v510.ProduceMessageReply)1 ProduceMessageReply (com.swiftmq.jms.smqp.v600.ProduceMessageReply)1 ProduceMessageRequest (com.swiftmq.jms.smqp.v600.ProduceMessageRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v610.ProduceMessageReply)1 ProduceMessageRequest (com.swiftmq.jms.smqp.v610.ProduceMessageRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v630.ProduceMessageReply)1 ProduceMessageRequest (com.swiftmq.jms.smqp.v630.ProduceMessageRequest)1 ProduceMessageReply (com.swiftmq.jms.smqp.v750.ProduceMessageReply)1 ProduceMessageRequest (com.swiftmq.jms.smqp.v750.ProduceMessageRequest)1