Exemplo n.º 1
0
 @Override
 public double getDoubleProperty(String name) {
   try {
     return properties.getDoubleProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
     throw new MessageFormatRuntimeException(ce.getMessage());
   }
 }
Exemplo n.º 2
0
 @Override
 public JMSProducer setProperty(String name, String value) {
   checkName(name);
   SimpleString key = new SimpleString(name);
   properties.putSimpleStringProperty(key, new SimpleString(value));
   stringPropertyNames.add(key);
   return this;
 }
Exemplo n.º 3
0
 @Override
 public boolean getBooleanProperty(String name) {
   try {
     return properties.getBooleanProperty(new SimpleString(name));
   } catch (ActiveMQPropertyConversionException ce) {
     throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
     throw new JMSRuntimeException(e.getMessage());
   }
 }
Exemplo n.º 4
0
 @Override
 public JMSProducer clearProperties() {
   try {
     stringPropertyNames.clear();
     properties.clear();
   } catch (RuntimeException e) {
     throw new JMSRuntimeException(e.getMessage());
   }
   return this;
 }
Exemplo n.º 5
0
 @Override
 public String getStringProperty(String name) {
   try {
     SimpleString prop = properties.getSimpleStringProperty(new SimpleString(name));
     if (prop == null) return null;
     return prop.toString();
   } catch (ActiveMQPropertyConversionException ce) {
     throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
     throw new JMSRuntimeException(e.getMessage());
   }
 }
Exemplo n.º 6
0
 @Override
 public JMSProducer setProperty(String name, Object value) {
   checkName(name);
   try {
     TypedProperties.setObjectProperty(new SimpleString(name), value, properties);
   } catch (ActiveMQPropertyConversionException amqe) {
     throw new MessageFormatRuntimeException(amqe.getMessage());
   } catch (RuntimeException e) {
     throw new JMSRuntimeException(e.getMessage());
   }
   return this;
 }
Exemplo n.º 7
0
 @Override
 public Object getObjectProperty(String name) {
   try {
     SimpleString key = new SimpleString(name);
     Object property = properties.getProperty(key);
     if (stringPropertyNames.contains(key)) {
       property = property.toString();
     }
     return property;
   } catch (ActiveMQPropertyConversionException ce) {
     throw new MessageFormatRuntimeException(ce.getMessage());
   } catch (RuntimeException e) {
     throw new JMSRuntimeException(e.getMessage());
   }
 }
Exemplo n.º 8
0
  @Override
  public Set<String> getPropertyNames() {
    try {
      Set<SimpleString> simplePropNames = properties.getPropertyNames();
      Set<String> propNames = new HashSet<String>(simplePropNames.size());

      for (SimpleString str : simplePropNames) {
        propNames.add(str.toString());
      }
      return propNames;
    } catch (ActiveMQPropertyConversionException ce) {
      throw new MessageFormatRuntimeException(ce.getMessage());
    } catch (RuntimeException e) {
      throw new JMSRuntimeException(e.getMessage());
    }
  }
Exemplo n.º 9
0
 @Override
 public boolean propertyExists(String name) {
   return properties.containsProperty(new SimpleString(name));
 }
Exemplo n.º 10
0
 @Override
 public JMSProducer setProperty(String name, double value) {
   checkName(name);
   properties.putDoubleProperty(new SimpleString(name), value);
   return this;
 }
Exemplo n.º 11
0
 @Override
 public JMSProducer setProperty(String name, boolean value) {
   checkName(name);
   properties.putBooleanProperty(new SimpleString(name), value);
   return this;
 }
Exemplo n.º 12
0
 /**
  * Sets all properties we carry onto the message.
  *
  * @param message
  * @throws JMSException
  */
 private void setProperties(Message message) throws JMSException {
   for (SimpleString name : properties.getPropertyNames()) {
     message.setObjectProperty(name.toString(), properties.getProperty(name));
   }
 }
Exemplo n.º 13
0
  @Override
  public ServerConsumer createConsumer(
      final long consumerID,
      final SimpleString queueName,
      final SimpleString filterString,
      final boolean browseOnly,
      final boolean supportLargeMessage,
      final Integer credits)
      throws Exception {
    if (this.internal) {
      // internal sessions doesn't check security

      Binding binding = postOffice.getBinding(queueName);

      if (binding == null || binding.getType() != BindingType.LOCAL_QUEUE) {
        throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(queueName);
      }

      Filter filter = FilterImpl.createFilter(filterString);

      ServerConsumer consumer =
          newConsumer(
              consumerID,
              this,
              (QueueBinding) binding,
              filter,
              started,
              browseOnly,
              storageManager,
              callback,
              preAcknowledge,
              strictUpdateDeliveryCount,
              managementService,
              supportLargeMessage,
              credits);
      consumers.put(consumer.getID(), consumer);

      if (!browseOnly) {
        TypedProperties props = new TypedProperties();

        props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());

        props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());

        props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());

        props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());

        Queue theQueue = (Queue) binding.getBindable();

        props.putIntProperty(ManagementHelper.HDR_CONSUMER_COUNT, theQueue.getConsumerCount());

        // HORNETQ-946
        props.putSimpleStringProperty(
            ManagementHelper.HDR_USER, SimpleString.toSimpleString(username));

        props.putSimpleStringProperty(
            ManagementHelper.HDR_REMOTE_ADDRESS,
            SimpleString.toSimpleString(this.remotingConnection.getRemoteAddress()));

        props.putSimpleStringProperty(
            ManagementHelper.HDR_SESSION_NAME, SimpleString.toSimpleString(name));

        if (filterString != null) {
          props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString);
        }

        Notification notification =
            new Notification(null, CoreNotificationType.CONSUMER_CREATED, props);

        if (ActiveMQServerLogger.LOGGER.isDebugEnabled()) {
          ActiveMQServerLogger.LOGGER.debug(
              "Session with user="******", connection="
                  + this.remotingConnection
                  + " created a consumer on queue "
                  + queueName
                  + ", filter = "
                  + filterString);
        }

        managementService.sendNotification(notification);
      }

      return consumer;
    } else {
      return super.createConsumer(
          consumerID, queueName, filterString, browseOnly, supportLargeMessage, credits);
    }
  }