private void register() {
		if (brokerUrl == null
				|| registryId == null
				|| (System.currentTimeMillis() - lastRegistered > 10 * 1000)) {
			Response response = null;
			if(getType().equals("producer")){
				response = Announce.callAsProducer(getLocation());
			} else {
				response = Announce.callAsConsumer(registryId, brokerUrl, getLocation(), ((Consumer)this).interestRadius);
			}
			if(response != null){
				JSONObject obj = (JSONObject) JSONValue.parse(response.body);
				this.registryId = (String)obj.get("consumer_id");
				this.brokerUrl = (String)obj.get("broker_url");
				if(brokerUrl != null){
					brokerUrl = brokerUrl.substring(7, brokerUrl.length()-1);
				}
			}
			lastRegistered = System.currentTimeMillis();
		}
		if (getType().equals("consumer") && registryId ==null) {
			System.err.println("Error getting consumerId "+getType()+" "+name+" from registery");
		}
		if (brokerUrl == null) {
			System.err.println("Error getting brokerUrl "+getType()+" "+name+" with registery");
		}
	}