jakartaee / jakartaee/messaging
add method Destination.getName()
- Dominant language
- Java
- Stars
- 49
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
JMS topics and queues both have names that are accessible with getTopicName() and getQueueName(), but for applications where the type of destination (topic or queue) is configurable - which I would consider a good application - it's difficult to get the actual destination's name.
An ugly typecast or something similar must be used:
```
public static String getJMSDestinationName(Message msg) throws JMSException
{
Destination origDest = msg.getJMSDestination();
if( origDest==null ) return null;
if( origDest instanceof Topic) {
return ((Topic)origDest).getTopicName();
}
else {
return ((Queue)origDest).getQueueName();
}
}
```
What I'm proposing is simply a common Destination.getName() method so this code becomes nicer:
```
public static String getJMSDestinationName(Message msg) throws JMSException
{
return msg.getJMSDestination().getName();
}
```
The implementation of Destination.getName() is trivial for Topic and Queue.
I can understand the objection of saying: "'Destination' is just a marker interface and JMS abstracts from the actual topic/queue name, these names shouldn't matter."
But then, why is there getQueueName()/getTopicName() in the first place?
I find this name very useful in order to debug or sort message streams into buckets and it would be nice if this name will be simpler to get by.
#### Affected Versions
[2.0]
Contributor guide
Research direction
Start by reviewing the Destination, Topic, and Queue interfaces named in the issue, along with the six-comment discussion. Assess the proposed common name access against the existing type-specific methods; done requires a resolved API decision and corresponding changes for the affected messaging interfaces and implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100