@Override public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { // Only consumers on the same connection can consume from // the temporary destination // However, we could have failed over - and we do this // check client side anyways .... if (!context.isFaultTolerant() && (!context.isNetworkConnection() && !tempDest .getConnectionId().equals( sub.getConsumerInfo().getConsumerId() .getConnectionId()))) { tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId()); LOG.debug("changed ownership of {} to {}", this, tempDest.getConnectionId()); } super.addSubscription(context, sub); }
public void setPhysicalName(String physicalName) { super.setPhysicalName(physicalName); if (!isComposite()) { // Parse off the sequenceId off the end. // this can fail if the temp destination is // generated by another JMS system via the JMS<->JMS Bridge int p = this.physicalName.lastIndexOf(":"); if (p >= 0) { String seqStr = this.physicalName.substring(p + 1).trim(); if (seqStr != null && seqStr.length() > 0) { try { sequenceId = Integer.parseInt(seqStr); } catch (NumberFormatException e) { LOG.debug("Did not parse sequence Id from " + physicalName); } // The rest should be the connection id. connectionId = this.physicalName.substring(0, p); } } } }
/** * Create the DestinationInfo object for the temporary destination. * * @param topic - if its true topic, else queue. * @return DestinationInfo * @throws JMSException */ protected ActiveMQTempDestination createTempDestination(boolean topic) throws JMSException { // Check if Destination info is of temporary type. ActiveMQTempDestination dest; if (topic) { dest = new ActiveMQTempTopic(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } else { dest = new ActiveMQTempQueue(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE); info.setDestination(dest); syncSendPacket(info); dest.setConnection(this); activeTempDestinations.put(dest, dest); return dest; }
private void processDestinationInfo(DestinationInfo dinfo) { ActiveMQDestination dest = dinfo.getDestination(); if (!dest.isTemporary()) { return; } ActiveMQTempDestination tempDest = (ActiveMQTempDestination)dest; if (dinfo.getOperationType() == DestinationInfo.ADD_OPERATION_TYPE) { if (tempDest.getConnection() != null) { tempDest = (ActiveMQTempDestination) tempDest.createDestination(tempDest.getPhysicalName()); } connection.activeTempDestinations.put(tempDest, tempDest); } else if (dinfo.getOperationType() == DestinationInfo.REMOVE_OPERATION_TYPE) { connection.activeTempDestinations.remove(tempDest); } }
/** * Removes any TempDestinations that this connection has cached, ignoring * any exceptions generated because the destination is in use as they should * not be removed. * Used from a pooled connection, b/c it will not be explicitly closed. */ public void cleanUpTempDestinations() { if (this.activeTempDestinations == null || this.activeTempDestinations.isEmpty()) { return; } Iterator<ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination>> entries = this.activeTempDestinations.entrySet().iterator(); while(entries.hasNext()) { ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination> entry = entries.next(); try { // Only delete this temp destination if it was created from this connection. The connection used // for the advisory consumer may also have a reference to this temp destination. ActiveMQTempDestination dest = entry.getValue(); String thisConnectionId = (info.getConnectionId() == null) ? "" : info.getConnectionId().toString(); if (dest.getConnectionId() != null && dest.getConnectionId().equals(thisConnectionId)) { this.deleteTempDestination(entry.getValue()); } } catch (Exception ex) { // the temp dest is in use so it can not be deleted. // it is ok to leave it to connection tear down phase } } }
tempDest.setConnectionId(localSessionInfo.getSessionId().getConnectionId());
/** * Removes any TempDestinations that this connection has cached, ignoring * any exceptions generated because the destination is in use as they should * not be removed. * Used from a pooled connection, b/c it will not be explicitly closed. */ public void cleanUpTempDestinations() { if (this.activeTempDestinations == null || this.activeTempDestinations.isEmpty()) { return; } Iterator<ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination>> entries = this.activeTempDestinations.entrySet().iterator(); while(entries.hasNext()) { ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination> entry = entries.next(); try { // Only delete this temp destination if it was created from this connection. The connection used // for the advisory consumer may also have a reference to this temp destination. ActiveMQTempDestination dest = entry.getValue(); String thisConnectionId = (info.getConnectionId() == null) ? "" : info.getConnectionId().toString(); if (dest.getConnectionId() != null && dest.getConnectionId().equals(thisConnectionId)) { this.deleteTempDestination(entry.getValue()); } } catch (Exception ex) { // the temp dest is in use so it can not be deleted. // it is ok to leave it to connection tear down phase } } }
private void processDestinationInfo(DestinationInfo dinfo) { ActiveMQDestination dest = dinfo.getDestination(); if (!dest.isTemporary()) { return; } ActiveMQTempDestination tempDest = (ActiveMQTempDestination)dest; if (dinfo.getOperationType() == DestinationInfo.ADD_OPERATION_TYPE) { if (tempDest.getConnection() != null) { tempDest = (ActiveMQTempDestination) tempDest.createDestination(tempDest.getPhysicalName()); } connection.activeTempDestinations.put(tempDest, tempDest); } else if (dinfo.getOperationType() == DestinationInfo.REMOVE_OPERATION_TYPE) { connection.activeTempDestinations.remove(tempDest); } }
protected DemandSubscription doCreateDemandSubscription(ConsumerInfo info) throws IOException { DemandSubscription result = new DemandSubscription(info); result.getLocalInfo().setConsumerId(new ConsumerId(localSessionInfo.getSessionId(), consumerIdGenerator.getNextSequenceId())); if (info.getDestination().isTemporary()) { // reset the local connection Id ActiveMQTempDestination dest = (ActiveMQTempDestination) result.getLocalInfo().getDestination(); dest.setConnectionId(localConnectionInfo.getConnectionId().toString()); } if (configuration.isDecreaseNetworkConsumerPriority()) { byte priority = (byte) configuration.getConsumerPriorityBase(); if (info.getBrokerPath() != null && info.getBrokerPath().length > 1) { // The longer the path to the consumer, the less it's consumer priority. priority -= info.getBrokerPath().length + 1; } result.getLocalInfo().setPriority(priority); LOG.debug("{} using priority: {} for subscription: {}", new Object[]{configuration.getBrokerName(), priority, info}); } configureDemandSubscription(info, result); return result; }
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { // Only consumers on the same connection can consume from // the temporary destination // However, we could have failed over - and we do this // check client side anyways .... if (!context.isFaultTolerant() && (!context.isNetworkConnection() && !tempDest .getConnectionId().equals( sub.getConsumerInfo().getConsumerId() .getConnectionId()))) { tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId()); if (LOG.isDebugEnabled()) { LOG.debug(" changed ownership of " + this + " to "+ tempDest.getConnectionId()); } } super.addSubscription(context, sub); }
/** * Removes any TempDestinations that this connection has cached, ignoring * any exceptions generated because the destination is in use as they should * not be removed. * Used from a pooled connection, b/c it will not be explicitly closed. */ public void cleanUpTempDestinations() { if (this.activeTempDestinations == null || this.activeTempDestinations.isEmpty()) { return; } Iterator<ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination>> entries = this.activeTempDestinations.entrySet().iterator(); while(entries.hasNext()) { ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination> entry = entries.next(); try { // Only delete this temp destination if it was created from this connection. The connection used // for the advisory consumer may also have a reference to this temp destination. ActiveMQTempDestination dest = entry.getValue(); String thisConnectionId = (info.getConnectionId() == null) ? "" : info.getConnectionId().toString(); if (dest.getConnectionId() != null && dest.getConnectionId().equals(thisConnectionId)) { this.deleteTempDestination(entry.getValue()); } } catch (Exception ex) { // the temp dest is in use so it can not be deleted. // it is ok to leave it to connection tear down phase } } }
private void processDestinationInfo(DestinationInfo dinfo) { ActiveMQDestination dest = dinfo.getDestination(); if (!dest.isTemporary()) { return; } ActiveMQTempDestination tempDest = (ActiveMQTempDestination)dest; if (dinfo.getOperationType() == DestinationInfo.ADD_OPERATION_TYPE) { if (tempDest.getConnection() != null) { tempDest = (ActiveMQTempDestination) tempDest.createDestination(tempDest.getPhysicalName()); } connection.activeTempDestinations.put(tempDest, tempDest); } else if (dinfo.getOperationType() == DestinationInfo.REMOVE_OPERATION_TYPE) { connection.activeTempDestinations.remove(tempDest); } }
tempDest.setConnectionId(localSessionInfo.getSessionId().getConnectionId());
public void setPhysicalName(String physicalName) { super.setPhysicalName(physicalName); if (!isComposite()) { // Parse off the sequenceId off the end. // this can fail if the temp destination is // generated by another JMS system via the JMS<->JMS Bridge int p = this.physicalName.lastIndexOf(":"); if (p >= 0) { String seqStr = this.physicalName.substring(p + 1).trim(); if (seqStr != null && seqStr.length() > 0) { try { sequenceId = Integer.parseInt(seqStr); } catch (NumberFormatException e) { LOG.debug("Did not parse sequence Id from " + physicalName); } // The rest should be the connection id. connectionId = this.physicalName.substring(0, p); } } } }
/** * Create the DestinationInfo object for the temporary destination. * * @param topic - if its true topic, else queue. * @return DestinationInfo * @throws JMSException */ protected ActiveMQTempDestination createTempDestination(boolean topic) throws JMSException { // Check if Destination info is of temporary type. ActiveMQTempDestination dest; if (topic) { dest = new ActiveMQTempTopic(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } else { dest = new ActiveMQTempQueue(info.getConnectionId(), tempDestinationIdGenerator.getNextSequenceId()); } DestinationInfo info = new DestinationInfo(); info.setConnectionId(this.info.getConnectionId()); info.setOperationType(DestinationInfo.ADD_OPERATION_TYPE); info.setDestination(dest); syncSendPacket(info); dest.setConnection(this); activeTempDestinations.put(dest, dest); return dest; }
public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { // Only consumers on the same connection can consume from // the temporary destination // However, we could have failed over - and we do this // check client side anyways .... if (!context.isFaultTolerant() && (!context.isNetworkConnection() && !tempDest .getConnectionId().equals( sub.getConsumerInfo().getConsumerId() .getConnectionId()))) { tempDest.setConnectionId(sub.getConsumerInfo().getConsumerId().getConnectionId()); if (LOG.isDebugEnabled()) { LOG.debug(" changed ownership of " + this + " to "+ tempDest.getConnectionId()); } } super.addSubscription(context, sub); }
/** * Removes any TempDestinations that this connection has cached, ignoring * any exceptions generated because the destination is in use as they should * not be removed. * Used from a pooled connection, b/c it will not be explicitly closed. */ public void cleanUpTempDestinations() { if (this.activeTempDestinations == null || this.activeTempDestinations.isEmpty()) { return; } Iterator<ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination>> entries = this.activeTempDestinations.entrySet().iterator(); while(entries.hasNext()) { ConcurrentMap.Entry<ActiveMQTempDestination, ActiveMQTempDestination> entry = entries.next(); try { // Only delete this temp destination if it was created from this connection. The connection used // for the advisory consumer may also have a reference to this temp destination. ActiveMQTempDestination dest = entry.getValue(); String thisConnectionId = (info.getConnectionId() == null) ? "" : info.getConnectionId().toString(); if (dest.getConnectionId() != null && dest.getConnectionId().equals(thisConnectionId)) { this.deleteTempDestination(entry.getValue()); } } catch (Exception ex) { // the temp dest is in use so it can not be deleted. // it is ok to leave it to connection tear down phase } } }
private void processDestinationInfo(DestinationInfo dinfo) { ActiveMQDestination dest = dinfo.getDestination(); if (!dest.isTemporary()) { return; } ActiveMQTempDestination tempDest = (ActiveMQTempDestination)dest; if (dinfo.getOperationType() == DestinationInfo.ADD_OPERATION_TYPE) { if (tempDest.getConnection() != null) { tempDest = (ActiveMQTempDestination) tempDest.createDestination(tempDest.getPhysicalName()); } connection.activeTempDestinations.put(tempDest, tempDest); } else if (dinfo.getOperationType() == DestinationInfo.REMOVE_OPERATION_TYPE) { connection.activeTempDestinations.remove(tempDest); } }
tempDest.setConnectionId(localSessionInfo.getSessionId().getConnectionId());
public void setPhysicalName(String physicalName) { super.setPhysicalName(physicalName); if (!isComposite()) { // Parse off the sequenceId off the end. // this can fail if the temp destination is // generated by another JMS system via the JMS<->JMS Bridge int p = this.physicalName.lastIndexOf(":"); if (p >= 0) { String seqStr = this.physicalName.substring(p + 1).trim(); if (seqStr != null && seqStr.length() > 0) { try { sequenceId = Integer.parseInt(seqStr); } catch (NumberFormatException e) { LOG.debug("Did not parse sequence Id from " + physicalName); } // The rest should be the connection id. connectionId = this.physicalName.substring(0, p); } } } }