[jira] [Created] (ARTEMIS-4339) Configure dead letter addresses through API

2023-06-29 Thread Chelsea Salyards (Jira)
Chelsea Salyards created ARTEMIS-4339:
-

 Summary: Configure dead letter addresses through API
 Key: ARTEMIS-4339
 URL: https://issues.apache.org/jira/browse/ARTEMIS-4339
 Project: ActiveMQ Artemis
  Issue Type: Wish
  Components: API
 Environment: Artemis client is 
org.apache.activemq:artemis-core-client:2.19.1, Java code is using the Artemis 
Core API.

Artemis server appears to be 2.28.0, and is running in a Docker container.
Reporter: Chelsea Salyards


My project is working on an integration with ActiveMQ Artemis, and it has the 
requirement to create queues and dead letter queues on the fly. When the queues 
are created, we want to be able to dynamically set the queue to use dead letter 
queues we just created and not just use the default dead letter address for the 
server. I would like to be able to do this through the Java API and the Artemis 
CLI.

[This 
page|https://activemq.apache.org/components/artemis/documentation/latest/undelivered-messages.html]
 documents how to set through the broker.xml, which will not work for our use 
case. I have seen references on the internet that suggest at one point the API 
allowed users to set dead letter addresses through the JMX API, but none of 
that seems to exist anymore.

The closest I have been able to accomplish this is through the following code:

{code:java}
String queueName = ... // whatever the name of the custom queue is
String deadLetterChannelName = // whatever the name of the custom 
dead letter address is
ActiveMQServerControl serverControl = ... // insert method to pull 
ActiveMQServerControl object from JMX
String jsonAddressSettings = 
serverControl.getAddressSettingsAsJSON(queueName);
AddressSettingsInfo defaultInfo = 
AddressSettingsInfo.from(jsonAddressSettings);

serverControl.addAddressSettings(
queueName, 
deadLetterChannelName,
deadLetterChannelName, 
defaultInfo.getExpiryDelay(),
false,
defaultInfo.getMaxDeliveryAttempts(), 
defaultInfo.getMaxSizeBytes(), 
defaultInfo.getPageSizeBytes(), 
defaultInfo.getPageCacheMaxSize(), 
defaultInfo.getRedeliveryDelay(), 
defaultInfo.getRedeliveryMultiplier(),
defaultInfo.getMaxRedeliveryDelay(), 
defaultInfo.getRedistributionDelay(), 
true,  
defaultInfo.getAddressFullMessagePolicy(), 
defaultInfo.getSlowConsumerThreshold(), 
defaultInfo.getSlowConsumerCheckPeriod(), 
defaultInfo.getSlowConsumerPolicy(), 
false, 
false, 
false, 
false 
{code}

Looking at the Artemis console this appears to be setting my custom dead letter 
address from the default, but I haven't figured out what happens if 
addAddressSettings() gets called multiple times or if there is a way to remove 
address settings later.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (ARTEMIS-4327) AMQBuffer.readNullableString() is returning null when the buffer is not empty

2023-06-28 Thread Chelsea Salyards (Jira)


[ 
https://issues.apache.org/jira/browse/ARTEMIS-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17738295#comment-17738295
 ] 

Chelsea Salyards commented on ARTEMIS-4327:
---

Thank you, this makes a lot of sense. I appreciate the details you provided!

>  AMQBuffer.readNullableString() is returning null when the buffer is not empty
> --
>
> Key: ARTEMIS-4327
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4327
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>Affects Versions: 2.19.1
> Environment: Artemis client is 
> org.apache.activemq:artemis-core-client:2.19.1, Java code is using the 
> Artemis Core API.
> Artemis server appears to be 2.28.0, and is running in a Docker container.
>Reporter: Chelsea Salyards
>Priority: Major
>
> *The Issue*
> Either I do not understand the intended functionality of 
> {{AMQBuffer.readNullableString()}}, or it is not functioning correctly. Based 
> on the name, I assumed that it would return {{null}} if the buffer was empty, 
> and if it was not, it would return a {{String}}.
> In my client code, I have the following: 
> {code:java}
> ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);
> ClientSessionFactory sessionFactory = locator.createSessionFactory();
> ClientSession session = sessionFactory.createSession();
> session.start();
> Client message = session.createMessage(true);
> message.getBodyBuffer().writeString("test string");
> logger.debug("Regular string: " + message.getDataBuffer().readString());
> logger.debug("Nullable string: " + 
> message.getDataBuffer().readNullableString());
> ClientProducer producer = session.createProducer("test-queue");
> producer.send(message);{code} 
> The first debug output, using {{readString()}} prints out the string "test 
> string" like I expect. However, the second debug output prints {{null}}, but 
> I expected it to print "test string".
> *Potential Cause*
> I took a look at the message in the queue via the Artemis web console, and I 
> can see the bytes for the message body are as follows:
> {noformat}
> 00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67{noformat}
> Looking at the Artemis client source code, particularly the code for 
> {{ChannelBufferWrapper}}, an implementation of the {{ActiveMQBuffer}} class, 
> I see that {{readNullableString()}} is defined as the following:
> activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java
> {code:java}
>    public String readNullableString() {
>   int b = buffer.readByte();
>   if (b == DataConstants.NULL) {
>  return null;
>     }
>   return readStringInternal();
>    }{code} 
> So if I am reading this correctly, this seems to be saying that if the buffer 
> starts with the byte {{00}}, it will return {{null}}, even if the buffer is 
> not empty. Am I reading this correctly? As shown in my example above, the 
> message body starts with byte {{00}}.
> Other details about the message, if it helps:
> * durable: true
> * protocol: CORE
> * type: default



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (ARTEMIS-4327) AMQBuffer.readNullableString() is returning null when the buffer is not empty

2023-06-22 Thread Chelsea Salyards (Jira)


 [ 
https://issues.apache.org/jira/browse/ARTEMIS-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chelsea Salyards updated ARTEMIS-4327:
--
Description: 
*The Issue*

Either I do not understand the intended functionality of 
AMQBuffer.readNullableString(), or it is not functioning correctly. Based on 
the name, I assumed that it would return null if the buffer was empty, and if 
it was not, it would return a string.

In my client code, I have the following:

 

ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);

ClientSessionFactory sessionFactory = locator.createSessionFactory();

ClientSession session = sessionFactory.createSession();

session.start();

Client message = session.createMessage(true);

message.getBodyBuffer().writeString("test string");

logger.debug("Regular string: " + message.getDataBuffer().readString());

logger.debug("Nullable string: " + 
message.getDataBuffer().readNullableString());

ClientProducer producer = session.createProducer("test-queue");

producer.send(message);

 

The first debug output, using readString() prints out the string "test string" 
like I expect.

 

However, the second debug output prints null, but I expected it to print "test 
string".

 

*Potential Cause*

I took a look at the message in the queue via the Artemis web console, and I 
can see the bytes for the message body are as follows:

 

00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67

 

Looking at the Artemis client source code, particularly the code for 
ChannelBufferWrapper, an implementation of the ActiveMQBuffer class, I see that 
readNullableString() is defined as the following:

 

activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java

   public String readNullableString() {
  int b = buffer.readByte();
  if (b == DataConstants.NULL) {
 return null;
    }

  return readStringInternal();
   }

 

So if I am reading this correctly, this seems to be saying that if the buffer 
starts with the byte 00, it will return null, even if the buffer is not empty. 
Am I reading this correctly? As shown in my example above, the message body 
starts with byte 00.

Other details about the message, if it helps:

durable: true

protocol: CORE

type: default

  was:
*The Issue*

Either I do not understand the intended functionality of 
AMQBuffer.readNullableString(), or it is not functioning correctly. Based on 
the name, I assumed that it would return null if the buffer was empty, and if 
it was not, it would return a string.

In my client code, I have the following:

 

ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);

ClientSessionFactory sessionFactory = locator.createSessionFactory();

ClientSession session = sessionFactory.createSession();

session.start();

Client message = session.createMessage(true);

message.getBodyBuffer().writeString("test string");

logger.debug("Regular string: " + message.getDataBuffer().readString());

logger.debug("Nullable string: " + 
message.getDataBuffer().readNullableString());

ClientProducer producer = session.createProducer("test-queue");

producer.send(message);

 

The first debug output, using readString() prints out the string "test string" 
like I expect.

 

However, the second debug output prints null, but I expected it to print "test 
string".

 

*Potential Cause*

I took a look at the message in the queue via the Artemis web console, and I 
can see the bytes for the message body are as follows:

 

00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67

 

Looking at the Artemis client source code, particularly the code for 
ChannelBufferWrapper, an implementation of the ActiveMQBuffer class, I see that 
readNullableString() is defined as the following:

 

activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java

   public String readNullableString() {
  int b = buffer.readByte();
  if (b == DataConstants.NULL)

{  return null;   }

  return readStringInternal();
   }

 

So if I am reading this correctly, this seems to be saying that if the buffer 
starts with the byte 00, it will return null, even if the buffer is not empty. 
Am I reading this correctly? As shown in my example above, the message body 
starts with byte 00.

Other details about the message, if it helps:

durable: true

protocol: CORE

type: default


>  AMQBuffer.readNullableString() is returning null when the buffer is not empty
> --
>
> Key: ARTEMIS-4327
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4327
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>  Components: ActiveMQ-Artemis-Native
>Affects Versions: 2.19.1
> Environment: Artemis client is 
> org

[jira] [Updated] (ARTEMIS-4327) AMQBuffer.readNullableString() is returning null when the buffer is not empty

2023-06-22 Thread Chelsea Salyards (Jira)


 [ 
https://issues.apache.org/jira/browse/ARTEMIS-4327?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chelsea Salyards updated ARTEMIS-4327:
--
Description: 
*The Issue*

Either I do not understand the intended functionality of 
AMQBuffer.readNullableString(), or it is not functioning correctly. Based on 
the name, I assumed that it would return null if the buffer was empty, and if 
it was not, it would return a string.

In my client code, I have the following:

 

ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);

ClientSessionFactory sessionFactory = locator.createSessionFactory();

ClientSession session = sessionFactory.createSession();

session.start();

Client message = session.createMessage(true);

message.getBodyBuffer().writeString("test string");

logger.debug("Regular string: " + message.getDataBuffer().readString());

logger.debug("Nullable string: " + 
message.getDataBuffer().readNullableString());

ClientProducer producer = session.createProducer("test-queue");

producer.send(message);

 

The first debug output, using readString() prints out the string "test string" 
like I expect.

 

However, the second debug output prints null, but I expected it to print "test 
string".

 

*Potential Cause*

I took a look at the message in the queue via the Artemis web console, and I 
can see the bytes for the message body are as follows:

 

00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67

 

Looking at the Artemis client source code, particularly the code for 
ChannelBufferWrapper, an implementation of the ActiveMQBuffer class, I see that 
readNullableString() is defined as the following:

 

activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java

   public String readNullableString() {
  int b = buffer.readByte();
  if (b == DataConstants.NULL)

{  return null;   }

  return readStringInternal();
   }

 

So if I am reading this correctly, this seems to be saying that if the buffer 
starts with the byte 00, it will return null, even if the buffer is not empty. 
Am I reading this correctly? As shown in my example above, the message body 
starts with byte 00.

Other details about the message, if it helps:

durable: true

protocol: CORE

type: default

  was:
*The Issue*

Either I do not understand the intended functionality of 
AMQBuffer.readNullableString(), or it is not functioning correctly. Based on 
the name, I assumed that it would return null if the buffer was empty, and if 
it was not, it would return a string.

In my client code, I have the following:

 

ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);

ClientSessionFactory sessionFactory = locator.createSessionFactory();

ClientSession session = sessionFactory.createSession();

session.start();

Client message = session.createMessage(true);

message.getBodyBuffer().writeString("test string");

logger.debug("Regular string: " + message.getDataBuffer().readString());

logger.debug("Nullable string: " + 
message.getDataBuffer().readNullableString());

ClientProducer producer = session.createProducer("test-queue");

producer.send(message);

 

The first debug output, using readString() prints out the string "test string" 
like I expect.

 

However, the second debug output prints null, but I expected it to print "test 
string".

 

*Potential Cause*

I took a look at the message in the queue via the Artemis web console, and I 
can see the bytes for the message body are as follows:

 

00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67

 

I took a look at the Artemis client source code, and looking at the code for 
ChannelBufferWrapper, an implementation of the ActiveMQBuffer class, I see that 
readNullableString() is defined as the following:

 

activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java

   public String readNullableString() {
  int b = buffer.readByte();
  if (b == DataConstants.NULL) {
 return null;
  }
  return readStringInternal();
   }

 

So if I am reading this correctly, this seems to be saying that if the buffer 
starts with the byte 00, it will return null, even if the buffer is not empty. 
Am I reading this correctly? As shown in my example above, the message body 
starts with byte 00.

Other details about the message, if it helps:

durable: true

protocol: CORE

type: default


>  AMQBuffer.readNullableString() is returning null when the buffer is not empty
> --
>
> Key: ARTEMIS-4327
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4327
> Project: ActiveMQ Artemis
>  Issue Type: Bug
>  Components: ActiveMQ-Artemis-Native
>Affects Versions: 2.19.1
> Environment: Artemis client 

[jira] [Created] (ARTEMIS-4327) AMQBuffer.readNullableString() is returning null when the buffer is not empty

2023-06-22 Thread Chelsea Salyards (Jira)
Chelsea Salyards created ARTEMIS-4327:
-

 Summary:  AMQBuffer.readNullableString() is returning null when 
the buffer is not empty
 Key: ARTEMIS-4327
 URL: https://issues.apache.org/jira/browse/ARTEMIS-4327
 Project: ActiveMQ Artemis
  Issue Type: Bug
  Components: ActiveMQ-Artemis-Native
Affects Versions: 2.19.1
 Environment: Artemis client is 
org.apache.activemq:artemis-core-client:2.19.1, Java code is using the Artemis 
Core API.

Artemis server appears to be 2.28.0, and is running in a Docker container.
Reporter: Chelsea Salyards
Assignee: Clebert Suconic


*The Issue*

Either I do not understand the intended functionality of 
AMQBuffer.readNullableString(), or it is not functioning correctly. Based on 
the name, I assumed that it would return null if the buffer was empty, and if 
it was not, it would return a string.

In my client code, I have the following:

 

ServerLocator locator = ActiveMQClient.createServerLocator(AMQ_BROKER_URL);

ClientSessionFactory sessionFactory = locator.createSessionFactory();

ClientSession session = sessionFactory.createSession();

session.start();

Client message = session.createMessage(true);

message.getBodyBuffer().writeString("test string");

logger.debug("Regular string: " + message.getDataBuffer().readString());

logger.debug("Nullable string: " + 
message.getDataBuffer().readNullableString());

ClientProducer producer = session.createProducer("test-queue");

producer.send(message);

 

The first debug output, using readString() prints out the string "test string" 
like I expect.

 

However, the second debug output prints null, but I expected it to print "test 
string".

 

*Potential Cause*

I took a look at the message in the queue via the Artemis web console, and I 
can see the bytes for the message body are as follows:

 

00 00 00 0b 00 0b 74 65 73 74 20 73 74 72 69 6e 67

 

I took a look at the Artemis client source code, and looking at the code for 
ChannelBufferWrapper, an implementation of the ActiveMQBuffer class, I see that 
readNullableString() is defined as the following:

 

activemq-artemis/artemis-commons/src/main/java/org/apache/activemq/artemis/core/buffers/impl/ChannelBufferWrapper.java

   public String readNullableString() {
  int b = buffer.readByte();
  if (b == DataConstants.NULL) {
 return null;
  }
  return readStringInternal();
   }

 

So if I am reading this correctly, this seems to be saying that if the buffer 
starts with the byte 00, it will return null, even if the buffer is not empty. 
Am I reading this correctly? As shown in my example above, the message body 
starts with byte 00.

Other details about the message, if it helps:

durable: true

protocol: CORE

type: default



--
This message was sent by Atlassian Jira
(v8.20.10#820010)