use of com.swiftmq.jms.smqp.v500.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);
}
}
use of com.swiftmq.jms.smqp.v500.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);
}
use of com.swiftmq.jms.smqp.v500.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());
}
}
use of com.swiftmq.jms.smqp.v500.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);
}
use of com.swiftmq.jms.smqp.v500.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);
}
}
Aggregations