Search code examples
javaakkashardingakka-clustertelemetry

Envelop is not being routed to akka cluster sharded actor while using old cinnamon-agent.jar


I am actually posting an experience. Maybe I'll save someone's time.

Summary:

Sometimes Akka cluster sharded Actor will not receive any routed messages and the reason is the old cinnamon agent used (i have no idea how but i have evidence).

Details:

I have an Akka Java project. We have pushed the cinnamon-agent.jar (some months ago) to the codebase and one can point to it while running the app using standard JVM option:

-javaagent:.local/cinnamon-agent.jar

Some days ago I tried to activate Lightbend Telemetry by using the above option. Suddenly I realised that routing mechanism of akka cluster sharding is not working any more. The target actor and even the ShardRegion.MessageExtractor implementation were not being executed and message would be somehow lost without any log even in DEBUG level.

It took 2 days for me to find out its related to the cinnamon agent! But surprisingly by changing the jar file with a new one (fetched by build plugin) the problem was resolved.


Solution

  • Use build tool plugin to fetch a new cinnamon-agent.jar:

    Maven:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <version>3.1.1</version>
      <executions>
        <execution>
          <id>copy</id>
          <phase>compile</phase>
          <goals>
            <goal>copy</goal>
          </goals>
          <configuration>
            <artifactItems>
              <artifactItem>
                <groupId>com.lightbend.cinnamon</groupId>
                <artifactId>cinnamon-agent</artifactId>
                <version>2.15.0</version>
                <overWrite>true</overWrite>
                <destFileName>cinnamon-agent.jar</destFileName>
              </artifactItem>
            </artifactItems>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    Gradle:

    // Add the agent to a separate configuration so it doesn't add to the normal class path
    configurations {
      agent
    }
    
    dependencies {
      agent group: 'com.lightbend.cinnamon', name: 'cinnamon-agent', version: '2.15.0'
    }
    

    Further info:

    Lightbend Telemetry Setup

    Add agent as javaagent VM Option to your run:

    java -jar -javaagent:.local/cinnamon-agent.jar your-app.jar