Skip to content

Commit

Permalink
Updating serviceBus to map custom properties. Fixes Azure#72
Browse files Browse the repository at this point in the history
  • Loading branch information
lodejard committed Nov 23, 2011
1 parent cdb9e1f commit 81641be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class ServiceBusRestProxy implements ServiceBusContract {
private Client channel;
private final String uri;
private final BrokerPropertiesMapper mapper;
private final CustomPropertiesMapper customPropertiesMapper;
static Log log = LogFactory.getLog(ServiceBusContract.class);

ServiceFilter[] filters;
Expand All @@ -64,6 +65,7 @@ public ServiceBusRestProxy(Client channel, @Named("serviceBus") WrapFilter authF
this.filters = new ServiceFilter[0];
this.uri = uri;
this.mapper = mapper;
this.customPropertiesMapper = new CustomPropertiesMapper();
channel.addFilter(authFilter);
}

Expand All @@ -72,6 +74,7 @@ public ServiceBusRestProxy(Client channel, ServiceFilter[] filters, String uri,
this.filters = filters;
this.uri = uri;
this.mapper = mapper;
this.customPropertiesMapper = new CustomPropertiesMapper();
}

@Override
Expand Down Expand Up @@ -107,6 +110,10 @@ public void sendMessage(String path, BrokeredMessage message) {
if (message.getBrokerProperties() != null)
request = request.header("BrokerProperties", mapper.toString(message.getBrokerProperties()));

for (java.util.Map.Entry<String, Object> entry : message.getProperties().entrySet()) {
request.header(entry.getKey(), customPropertiesMapper.toString(entry.getValue()));
}

request.post(message.getBody());
}

Expand Down Expand Up @@ -190,6 +197,11 @@ else if (options.isPeekLock()) {
message.setBody(body);
}

for (String key : clientResult.getHeaders().keySet()) {
Object value = clientResult.getHeaders().getFirst(key);
message.setProperty(key, value);
}

return message;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ public BrokeredMessage setProperty(String name, Object value) {
return this;
}

/**
* Returns the user defined properties of the message.
*
* @return A <code>Map</code> object that represents the user defined properties.
*/
public Map<String, Object> getProperties() {
return customProperties;
}

/**
* Returns the delivery count of the message.
*
Expand Down

0 comments on commit 81641be

Please sign in to comment.