<div dir="ltr">Does this look right?<div><br></div><div>Map<String,object> headers = properties.getHeaders();</div><div><br></div><div>if (headers.containsKey("FirstName")) {</div><div> <span style="color:rgb(80,0,80)">String strFirstName = props.getHeaders().get("</span><span style="color:rgb(80,0,80)">FirstName").toString();</span></div>
<div><span style="color:rgb(80,0,80)">}</span></div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 30, 2014 at 12:18 PM, cw storm <span dir="ltr"><<a href="mailto:cwstorm@gmail.com" target="_blank">cwstorm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Thanks Tim. How do code to see if the key is there or not?</div>
<div class=""><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 30, 2014 at 11:58 AM, Tim Watson <span dir="ltr"><<a href="mailto:tim@rabbitmq.com" target="_blank">tim@rabbitmq.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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.<br>
<br>
Cheers,<br>
Tim<br>
<div><div><br>
On 30 Jan 2014, at 16:30, cw storm wrote:<br>
<br>
> 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:<br>
><br>
> String strFirstName = props.getHeaders().get("FirstName").toString()<br>
><br>
> I believe if there's no custom headers, then it'll exception.<br>
</div></div>> _______________________________________________<br>
> rabbitmq-discuss mailing list<br>
> <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
> <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>