[rabbitmq-discuss] How to check if custom headers attribute exist

cw storm cwstorm at gmail.com
Thu Jan 30 17:18:59 GMT 2014


Thanks Tim.  How do code to see if the key is there or not?


On Thu, Jan 30, 2014 at 11:58 AM, Tim Watson <tim at rabbitmq.com> wrote:

> BasicProperties#getHeaders() returns a Map, so Map#get(key) will return
> `null' if the key isn't present. It's your #toString() on `null' that is
> likely causing the problem. You could also call
> Map#containsKey("FirstName") instead of checking for `null' if you prefer.
>
> Cheers,
> Tim
>
> On 30 Jan 2014, at 16:30, cw storm wrote:
>
> > Please forgive me but I have a simple question.  How can I check to see
> if there's custom header attribute exist or not before I perform the below:
> >
> > String strFirstName = props.getHeaders().get("FirstName").toString()
> >
> > I believe if there's no custom headers, then it'll exception.
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-discuss at lists.rabbitmq.com
> > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140130/cb7ec20c/attachment.html>


More information about the rabbitmq-discuss mailing list