Refine search
/** * Write the booleans that this object uses to a BooleanStream */ public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException { RemoveInfo info = (RemoveInfo)o; int rc = super.tightMarshal1(wireFormat, o, bs); rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getObjectId(), bs); rc+=tightMarshalLong1(wireFormat, info.getLastDeliveredSequenceId(), bs); return rc + 0; }
public RemoveInfo createRemoveCommand() { RemoveInfo command = new RemoveInfo(getConnectionId()); command.setResponseRequired(isResponseRequired()); return command; }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); RemoveInfo info = (RemoveInfo)o; info.setObjectId((org.apache.activemq.command.DataStructure) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setLastDeliveredSequenceId(looseUnmarshalLong(wireFormat, dataIn)); }
public RemoveInfo createRemoveCommand() { RemoveInfo command = new RemoveInfo(getConsumerId()); command.setResponseRequired(isResponseRequired()); return command; }
public RemoveInfo createRemoveCommand() { RemoveInfo command = new RemoveInfo(getProducerId()); command.setResponseRequired(isResponseRequired()); return command; }
protected void displayRemoveInfo(final RemoveInfo removeInfo, final String startAdvisoryMsg) { switch(removeInfo.getObjectId().getDataStructureType()) { case CommandTypes.PRODUCER_INFO: ProducerInfo pi = (ProducerInfo)removeInfo.getObjectId(); output("Removed producer " + startAdvisoryMsg + pi.getProducerId().getConnectionId() + " that produced to destination: " + pi.getDestination().toString() ); break; case CommandTypes.CONSUMER_INFO: ConsumerInfo ci = (ConsumerInfo)removeInfo.getObjectId(); output("Removed consumer " + startAdvisoryMsg + ci.getConsumerId().getConnectionId() + " that consumed destination: " + ci.getDestination().toString()); break; case CommandTypes.CONNECTION_INFO: ConnectionInfo connInfo = (ConnectionInfo) removeInfo.getObjectId(); String connStr = connInfo.getUserName() != null ? connInfo.getUserName() + "@" + connInfo.getClientIp() : connInfo.getClientIp(); output("Removed connection " + startAdvisoryMsg + connInfo.getClientId() + " that connected from: " + connStr); break; } }
private void cleanupDurableSub(final DemandSubscription ds, Iterator<DemandSubscription> i) throws IOException { if (ds != null && ds.getLocalDurableSubscriber() != null && ds.getDurableRemoteSubs().isEmpty() && ds.getForcedDurableConsumersSize() == 0) { // deactivate subscriber RemoveInfo removeInfo = new RemoveInfo(ds.getLocalInfo().getConsumerId()); localBroker.oneway(removeInfo); // remove subscriber RemoveSubscriptionInfo sending = new RemoveSubscriptionInfo(); sending.setClientId(localClientId); sending.setSubscriptionName(ds.getLocalDurableSubscriber().getSubscriptionName()); sending.setConnectionId(this.localConnectionInfo.getConnectionId()); localBroker.oneway(sending); //remove subscriber from map i.remove(); } }
BrokerId[] path = info.getBrokerPath(); if (info.isBrowser()) { LOG.debug("{} Ignoring sub from {}, browsers explicitly suppressed", configuration.getBrokerName(), remoteBrokerName); return; if (!isPermissableDestination(info.getDestination())) { return; destInfo.setConnectionId(localConnectionInfo.getConnectionId()); if (destInfo.getDestination() instanceof ActiveMQTempDestination) { ConsumerId id = (ConsumerId) ((RemoveInfo) data).getObjectId(); removeDemandSubscription(id);
@Override public void run() { try { RemoveInfo removeCommand = subToClose.getConsumerInfo().createRemoveCommand(); if (connection instanceof CommandVisitor) { // avoid service exception handling and logging removeCommand.visit((CommandVisitor) connection); } else { connection.service(removeCommand); } } catch (IllegalStateException ignoredAsRemoteHasDoneTheJob) { } catch (Exception e) { LOG.info("exception on local remove of slow consumer: {}", subToClose.getConsumerInfo().getConsumerId(), e); } }}, 1000l);
void doClose() throws JMSException { dispose(); RemoveInfo removeCommand = info.createRemoveCommand(); LOG.debug("remove: {}, lastDeliveredSequenceId: {}", getConsumerId(), lastDeliveredSequenceId); removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId); this.session.asyncSendPacket(removeCommand); }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ConsumerInfo) { count = consumerCount.incrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStartedEvent(this, destination, (ConsumerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isConsumerRemove()) { count = consumerCount.decrementAndGet(); count = extractConsumerCountFromMessage(message, count); fireConsumerEvent(new ConsumerStoppedEvent(this, destination, (ConsumerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
public void onMessage(Message message) { if (message instanceof ActiveMQMessage) { ActiveMQMessage activeMessage = (ActiveMQMessage)message; Object command = activeMessage.getDataStructure(); int count = 0; if (command instanceof ProducerInfo) { count = producerCount.incrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStartedEvent(this, destination, (ProducerInfo)command, count)); } else if (command instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo)command; if (removeInfo.isProducerRemove()) { count = producerCount.decrementAndGet(); count = extractProducerCountFromMessage(message, count); fireProducerEvent(new ProducerStoppedEvent(this, destination, (ProducerId)removeInfo.getObjectId(), count)); } } else { LOG.warn("Unknown command: " + command); } } else { LOG.warn("Unknown message type: " + message + ". Message ignored"); } }
@Override public void registerConnectionStateListener(BiConsumer<String, ConnectionState> onStateChanged) { try { Destination dest = session.createTopic("ActiveMQ.Advisory.Connection"); MessageConsumer consumer = session.createConsumer(dest); consumer.setMessageListener((Message msg) -> { if (msg instanceof ActiveMQMessage) { ActiveMQMessage aMsg = (ActiveMQMessage) msg; if (aMsg.getDataStructure() instanceof ConnectionInfo) { ConnectionInfo dataStructure = (ConnectionInfo) aMsg.getDataStructure(); String clientID = AMQBasePeer.TrimConnectionID(dataStructure.getConnectionId().getValue()); threadPool.submit(() -> onStateChanged.accept(clientID, ConnectionState.CONNECTED)); } if (aMsg.getDataStructure() instanceof RemoveInfo) { RemoveInfo dataStructure = (RemoveInfo) aMsg.getDataStructure(); ConnectionId connectionId = (ConnectionId) dataStructure.getObjectId(); String clientID = AMQBasePeer.TrimConnectionID(connectionId.getValue()); threadPool.submit(() -> onStateChanged.accept(clientID, ConnectionState.DISCONNECTED)); } } }); advisoryConsumers.put("ActiveMQ.Advisory.Connection", consumer); } catch (JMSException e) { System.err.println("Error processing Advisory Message: " + e); } }
/** * A client is disconnecting from the broker. * * @param context the environment the operation is being executed under. * @param info * @param error null if the client requested the disconnect or the error * that caused the client to disconnect. * @throws Exception */ public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception { super.removeConnection(context, info, error); sendAsyncToSlave(new RemoveInfo(info.getConnectionId())); }
@Override public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { super.removeConsumer(context, info); consumers.remove(info.getConsumerId()); sendSyncToSlave(new RemoveInfo(info.getConsumerId())); }
/** * @return a new object instance */ public DataStructure createObject() { return new RemoveInfo(); }
/** * Write a object instance to data output stream * * @param o the instance to be marshaled * @param dataOut the output stream * @throws IOException thrown if an error occurs */ public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { super.tightMarshal2(wireFormat, o, dataOut, bs); RemoveInfo info = (RemoveInfo)o; tightMarshalCachedObject2(wireFormat, (DataStructure)info.getObjectId(), dataOut, bs); }
RemoveInfo removeCommand = info.createRemoveCommand(); removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId); try { syncSendPacket(removeCommand, closeTimeout);
RemoveInfo removeCommand = connectionInfo.createRemoveCommand(); removeCommand.setResponseRequired(false); removeCommand.setLastDeliveredSequenceId(l);
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); RemoveInfo info = (RemoveInfo)o; info.setObjectId((org.apache.activemq.command.DataStructure) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); }