use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationManagerMonitor method getDestinations.
public ObjectName[] getDestinations() throws MBeanException {
List dests = DestinationUtil.getVisibleDestinations();
if (dests.size() == 0) {
return (null);
}
ObjectName[] destONames = new ObjectName[dests.size()];
for (int i = 0; i < dests.size(); i++) {
Destination d = (Destination) dests.get(i);
try {
ObjectName o = MQObjectName.createDestinationMonitor(d.isQueue() ? DestinationType.QUEUE : DestinationType.TOPIC, d.getDestinationName());
destONames[i] = o;
} catch (Exception e) {
handleOperationException(DestinationOperations.GET_DESTINATIONS, e);
}
}
return (destONames);
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationManagerConfig method getDestinations.
public ObjectName[] getDestinations() throws MBeanException {
List dests = DestinationUtil.getVisibleDestinations();
if (dests.size() == 0) {
return (null);
}
ObjectName[] destONames = new ObjectName[dests.size()];
for (int i = 0; i < dests.size(); i++) {
Destination d = (Destination) dests.get(i);
try {
ObjectName o = MQObjectName.createDestinationConfig(d.isQueue() ? DestinationType.QUEUE : DestinationType.TOPIC, d.getDestinationName());
destONames[i] = o;
} catch (Exception e) {
handleOperationException(DestinationOperations.GET_DESTINATIONS, e);
}
}
return (destONames);
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class ProtocolImpl method processMessage.
/**
* route, store and forward a message
*/
@Override
public void processMessage(IMQConnection con, Packet msg) throws BrokerException, SelectorFormatException, IOException {
DataHandler handler = (DataHandler) pr.getHandler(PacketType.MESSAGE);
Destination d = null;
PacketReference ref = null;
Set s = null;
boolean route = false;
boolean isadmin = con.isAdminConnection();
List<MessageDeliveryTimeInfo> deliveryDelayReadyList = new ArrayList<>();
try {
Destination[] ds = DL.getDestination(con.getPartitionedStore(), msg.getDestination(), msg.getIsQueue());
d = ds[0];
if (d == null) {
throw new BrokerException("Unknown Destination:" + msg.getDestination());
}
Producer pausedProducer = handler.checkFlow(msg, con);
boolean transacted = (msg.getTransactionID() != 0);
if (DEBUG) {
logger.log(Logger.INFO, "ProtocolImpl.PROCESS MESSAGE[" + msg + "]TID=" + msg.getTransactionID() + " to destination " + d + ", on conn=@" + con.hashCode() + "[" + con.getConnectionUID() + ", " + con + "]");
}
// OK generate a ref. This checks message size and
// will be needed for later operations
ref = handler.createReference(msg, d.getDestinationUID(), con, isadmin);
// dont bother calling route if there are no messages
//
// to improve performance, we route and later forward
route = handler.queueMessage(d, ref, transacted);
s = handler.routeMessage(con.getPartitionedStore(), transacted, ref, route, d, deliveryDelayReadyList);
// handle producer flow control
handler.pauseProducer(d, pausedProducer, con);
} catch (BrokerException ex) {
int status = ex.getStatusCode();
if (status == Status.ERROR && ref != null && d != null) {
handler.cleanupOnError(d, ref);
}
// rethrow
throw ex;
}
if (route && s != null) {
try {
handler.forwardMessage(d, ref, s);
} catch (Exception e) {
Object[] emsg = { ref, d.getDestinationUID(), s };
logger.logStack(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.X_ROUTE_PRODUCED_MSG_FAIL, emsg), e);
}
}
if (deliveryDelayReadyList.size() > 0) {
MessageDeliveryTimeInfo di = null;
Iterator<MessageDeliveryTimeInfo> itr = deliveryDelayReadyList.iterator();
while (itr.hasNext()) {
di = itr.next();
di.setDeliveryReady();
}
}
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class GetMetricsHandler method handle.
/**
* Handle the incomming administration message.
*
* @param con The Connection the message came in on.
* @param cmd_msg The administration message
* @param cmd_props The properties from the administration message
*/
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
}
int status = Status.OK;
String errMsg = null;
String service = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
Integer type = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
Object replyobj = null;
String msgtype = null;
if (destination != null) {
try {
Destination[] ds = DL.getDestination(null, destination, DestType.isQueue((type == null ? 0 : type.intValue())));
// PART
Destination d = ds[0];
if (d == null) {
status = Status.NOT_FOUND;
int mytype = (type == null ? 0 : type.intValue());
errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
} else {
replyobj = d.getMetrics();
}
} catch (Exception ex) {
int mytype = (type == null ? 0 : type.intValue());
errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
status = Status.ERROR;
// log the error
logger.logStack(Logger.ERROR, rb.E_INTERNAL_BROKER_ERROR, this.getClass().getName() + ": failed to get destination (" + DestType.toString(mytype) + ":" + destination + ")", ex);
}
msgtype = "DESTINATION";
} else {
ServiceManager sm = Globals.getServiceManager();
MetricManager mm = Globals.getMetricManager();
MetricCounters mc = null;
if (service != null && sm.getServiceType(service) == ServiceType.UNKNOWN) {
status = Status.NOT_FOUND;
errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, service);
} else {
// If service is null getMetricCounters() will get counters
// for all services
mc = mm.getMetricCounters(service);
if (service != null) {
msgtype = "SERVICE";
}
replyobj = mc;
}
}
// Send reply
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
Hashtable pr = new Hashtable();
if (msgtype != null) {
pr.put(MessageType.JMQ_BODY_TYPE, msgtype);
}
setProperties(reply, MessageType.GET_METRICS_REPLY, status, errMsg, pr);
if (replyobj != null) {
setBodyObject(reply, replyobj);
}
parent.sendReply(con, cmd_msg, reply);
return true;
}
use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.
the class DestinationListStore method clearAll.
/**
* Clear all destinations
*/
void clearAll(boolean sync, boolean clearMessages) {
if (Store.getDEBUG()) {
logger.log(logger.DEBUGHIGH, "DestinationList.clearAll(" + clearMessages + ") called");
}
if (clearMessages) {
Iterator itr = dstMap.values().iterator();
while (itr.hasNext()) {
Destination dst = (Destination) itr.next();
DestinationUID dstuid = dst.getDestinationUID();
try {
parent.getMsgStore().releaseMessageDir(dstuid, sync);
} catch (IOException | BrokerException e) {
// log error and continue
logger.log(logger.ERROR, br.X_RELEASE_MSGFILE_FAILED, parent.getMsgStore().getDirName(dstuid), dstuid, e);
}
}
}
dstMap.clear();
if (sync) {
try {
sync();
} catch (BrokerException e) {
logger.log(logger.ERROR, "Got exception while synchronizing data to disk", e);
}
}
}
Aggregations