Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iot-dev): Fix unnecessary creation of custom symbol instances in amqp layer #1541

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

timtay-microsoft
Copy link
Member

Each new symbol instance is saved within proton-j's symbol cache. This cache lives as long as the proton-j reactor itself and cannot be manually cleared. That means that a multiplexed connection that is never closed and that has an infinite number of devices added and removed over time would cause the symbol cache to grow infinitely.

With this change, the only symbols in the symbol cache will be the constants used as property keys when building the amqp connection/sessions/links like the below:

// same value for every device, safe to save in the symbol cache
String CORRELATION_ID_PREFIX = "com.microsoft:channel-correlation-id"; 
Symbol key = Symbol.getSymbol(CORRELATION_ID_PREFIX);

// different value for every device. Cannot create a symbol since it would cause the cache to grow infinitely
String value = deviceId; 

// This map must be of type Map<Symbol, String> as per proton-j interface. Key cannot be a string
this.amqpProperties.put(key, value);

#1478

…amqp layer

Each new symbol instance is saved within proton-j's symbol cache and this cache lives as long as the reactor itself. That means that a multiplexed connection that is never closed and that has infinite devices added and removed over time would cause the symbol cache to grow infinitely.

With this change, the only symbols in the symbol cache will be the constants used as property keys when building the amqp connection/sessions/links like the below:

            this.amqpProperties.put(Symbol.getSymbol("com.microsoft:channel-correlation-id"), deviceId + "/" + moduleId);

#1478
@timtay-microsoft
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants