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

Robbie Gemmell commented on QPID-4224:
--------------------------------------

As per the code comments, it isn't possible to change the clientid after 
creating the Connection. This is because it is sent to the broker as a property 
during the connection establishment process, and there isn't a mechanism 
available in the protocol to send it later on.

So that you code isn't actually dependant on the underlying implementation 
classes as in Rajiths suggestion, you could instead create an InitialContext 
directly from a Properties object you have pre configured with appropriate base 
JNDI config properties and then manipulated the connection factory URL in the 
properties object (e.g do a string replace on the clientid for each client 
instance) before instantiating the InitialContext. (This would be as opposed to 
using the JVM sysem properties to set the context provider etc). Alternatively 
if you have to do it that way, you would just need to use a separate connection 
factory with its own unique URL string for each application instance.

{noformat}
Properties properties = new Properties();
  ...
  < manipulate properties object to contain the necessary details, e.g. load a 
base file and string replace the clientid in the connection factory url 
property >
  ...
InitialContext context = new InitialContext(properties);
{noformat}
                
> SetClientID does not have an effect
> -----------------------------------
>
>                 Key: QPID-4224
>                 URL: https://issues.apache.org/jira/browse/QPID-4224
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Broker
>    Affects Versions: 0.16
>         Environment: Windows 7 64-bit, Java 1.6
>            Reporter: Holger Caesar
>            Priority: Critical
>              Labels: AMQP, ClientID, JMS, QPID
>   Original Estimate: 96h
>  Remaining Estimate: 96h
>
> Hi everyone,
> I am currently evaluating QPID and AMQP in general. I have a JMS test 
> application that works perfectly on a JMS compliant broker (non AMQP) and now 
> I am trying to port it to QPID using only JMS features. Unfortunately I am 
> having problems changing the client ID. I am aware that I can specify it in 
> the AMQ://... string on startup, but since I want to read that string from a 
> single .properties file, that is not a nice solution for 200 clients in 
> parallel. Instead I tried using the setClientID method and setting the 
> ignore_setClientID flag. The only effect this had was to ignore the error 
> that is normally thrown.
> Below you can see the source code that basically does nothing other than 
> reporting the requested ID change. Is there any workaround or solution to 
> this problem??
> Thank you very much for your support,
> Holger
>     public void setClientID(String clientID) throws JMSException
>     {
>         checkNotClosed();
>         // in AMQP it is not possible to change the client ID. If one is not 
> specified
>         // upon connection construction, an id is generated automatically. 
> Therefore
>         // we can always throw an exception.
>         if 
> (!Boolean.getBoolean(ClientProperties.IGNORE_SET_CLIENTID_PROP_NAME))
>         {
>             throw new IllegalStateException("Client name cannot be changed 
> after being set");
>         }
>         else
>         {
>             _logger.info("Operation setClientID is ignored using ID: " + 
> getClientID());
>         }
>     }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to