public ProducerId(ProducerId id) { this.connectionId = id.getConnectionId(); this.sessionId = id.getSessionId(); this.value = id.getValue(); }
protected ProducerId createProducerId() { String id = idGenerator.generateId(); ConnectionId connectionId = new ConnectionId(id); SessionId sessionId = new SessionId(connectionId, 1); return new ProducerId(sessionId, 1); } }
public TransportConnectionState lookupConnectionState(ProducerId id) { TransportConnectionState cs = lookupConnectionState(id.getConnectionId()); if (cs == null) { throw new IllegalStateException( "Cannot lookup a producer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
/** * 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); ProducerId info = (ProducerId)o; info.setConnectionId(looseUnmarshalString(dataIn)); info.setValue(looseUnmarshalLong(wireFormat, dataIn)); info.setSessionId(looseUnmarshalLong(wireFormat, dataIn)); }
@Override public long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement(this.statements.getFindMessageSequenceIdStatement()); s.setString(1, messageID.getProducerId().toString()); s.setLong(2, messageID.getProducerSequenceId()); s.setString(3, destination.getQualifiedName()); rs = s.executeQuery(); if (!rs.next()) { return new long[]{0,0}; } return new long[]{rs.getLong(1), rs.getLong(2)}; } finally { close(rs); close(s); } }
@Override public void doUpdateMessage(TransactionContext c, ActiveMQDestination destination, MessageId id, byte[] data) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getUpdateMessageStatement()); setBinaryData(s, 1, data); s.setString(2, id.getProducerId().toString()); s.setLong(3, id.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); if (s.executeUpdate() != 1) { throw new IOException("Could not update message: " + id + " in " + destination); } } finally { close(s); } }
@Override public long doGetLastProducerSequenceId(TransactionContext c, ProducerId id) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement(this.statements.getLastProducerSequenceIdStatement()); s.setString(1, id.toString()); rs = s.executeQuery(); long seq = -1; if (rs.next()) { seq = rs.getLong(1); } return seq; } finally { close(rs); close(s); } }
/** * mark this message as being received * * @param id */ public void rollback(final MessageId id) { if (id != null) { ProducerId pid = id.getProducerId(); if (pid != null) { BitArrayBin bab = map.get(pid.toString()); if (bab != null) { bab.setBit(id.getProducerSequenceId(), false); modified = true; } } } }
public static ObjectName createProducerName(String brokerObjectName, String connectionClientId, ProducerInfo producerInfo) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; if (producerInfo.getDestination() == null) { objectNameStr += ",endpoint=dynamicProducer"; } else { objectNameStr += createDestinationProperties(producerInfo.getDestination()) + ",endpoint=Producer"; } objectNameStr += ",clientId=" + JMXSupport.encodeObjectNamePart(connectionClientId); objectNameStr += ",producerId=" + JMXSupport.encodeObjectNamePart(producerInfo.getProducerId().toString()); return new ObjectName(objectNameStr); }
@Override public Response processAddProducer(ProducerInfo info) throws Exception { SessionId sessionId = info.getProducerId().getParentId(); ConnectionId connectionId = sessionId.getParentId(); TransportConnectionState cs = lookupConnectionState(connectionId); if (cs == null) { if (!ss.getProducerIds().contains(info.getProducerId())) { ActiveMQDestination destination = info.getDestination();
public synchronized TransportConnectionState lookupConnectionState(ProducerId id) { TransportConnectionState cs = connectionState; if (cs == null) { throw new IllegalStateException( "Cannot lookup a producer from a connection that had not been registered: " + id.getParentId().getParentId()); } return cs; }
@Override public Response processAddProducer(ProducerInfo info) { if (info != null && info.getProducerId() != null) { SessionId sessionId = info.getProducerId().getParentId(); if (sessionId != null) { ConnectionId connectionId = sessionId.getParentId(); if (connectionId != null) { ConnectionState cs = connectionStates.get(connectionId); if (cs != null) { SessionState ss = cs.getSessionState(sessionId); if (ss != null) { ss.addProducer(info); if (info.isResponseRequired()) { return new Tracked(new ExceptionResponseCheckAction(info)); } } } } } } return TRACKED_RESPONSE_MARKER; }
private ProducerBrokerExchange getProducerBrokerExchange(ProducerId id) throws IOException { ProducerBrokerExchange result = producerExchanges.get(id); if (result == null) { synchronized (producerExchanges) { result = new ProducerBrokerExchange(); TransportConnectionState state = lookupConnectionState(id); context = state.getContext(); result.setConnectionContext(context); if (context.isReconnect() || (context.isNetworkConnection() && connector.isAuditNetworkProducers())) { result.setLastStoredSequenceId(brokerService.getPersistenceAdapter().getLastProducerSequenceId(id)); } SessionState ss = state.getSessionState(id.getParentId()); if (ss != null) { result.setProducerState(ss.getProducerState(id)); ProducerState producerState = ss.getProducerState(id); if (producerState != null && producerState.getInfo() != null) { ProducerInfo info = producerState.getInfo(); result.setMutable(info.getDestination() == null || info.getDestination().isComposite()); } } producerExchanges.put(id, result); } } else { context = result.getConnectionContext(); } return result; }
@Override public String getProducerId() { if (info != null) { return info.getProducerId().toString(); } return "NOTSET"; }
@Override public String getConnectionId() { if (info != null) { return info.getProducerId().getConnectionId(); } return "NOTSET"; }
public void addProducer(ProducerInfo info) { if (info != null && info.getProducerId() != null && info.getProducerId().getParentId() != null && info.getProducerId().getConnectionId() != null) { TransportConnectionState cs = lookupConnectionState(info.getProducerId().getConnectionId()); if (cs != null) { SessionState sessionState = cs.getSessionState(info.getProducerId().getParentId()); if (sessionState != null) { sessionState.addProducer(info); } } } }
/** * @return a new object instance */ public DataStructure createObject() { return new ProducerId(); }
@Override public long getSessionId() { if (info != null) { return info.getProducerId().getSessionId(); } return 0; }
if (m != null && m.getDataStructureType() == CommandTypes.ACTIVEMQ_BYTES_MESSAGE) { long producerSequenceId = m.getMessageId().getProducerSequenceId(); if (producerId == null) { producerId = m.getMessageId().getProducerId(); } else { if (!m.getMessageId().getProducerId().equals(producerId)) { throw new IOException("Received an unexpected message: invalid producer: " + m);