Skip to content

Pojo Listener byte[] to long Conversion Issue #1951

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

Closed
garyrussell opened this issue Sep 23, 2021 · 0 comments · Fixed by #1954
Closed

Pojo Listener byte[] to long Conversion Issue #1951

garyrussell opened this issue Sep 23, 2021 · 0 comments · Fixed by #1954
Assignees
Milestone

Comments

@garyrussell
Copy link
Contributor

	@DltHandler
	void handler(Message<?> msg,
			@Header(KafkaHeaders.ORIGINAL_OFFSET) long offset,
			@Header(KafkaHeaders.EXCEPTION_FQCN) String descException,
			@Header(KafkaHeaders.EXCEPTION_STACKTRACE) String stacktrace,
			@Header(KafkaHeaders.EXCEPTION_MESSAGE) String errorMessage) {
		System.out.println(msg);
		System.out.println(offset);
		System.out.println(descException);
		System.out.println(stacktrace);
		System.out.println(errorMessage);
	}

offset is always 0.

Work around:

	@DltHandler
	void handler(Message<?> msg,
			@Header(KafkaHeaders.ORIGINAL_OFFSET) byte[] offset,
			@Header(KafkaHeaders.EXCEPTION_FQCN) String descException,
			@Header(KafkaHeaders.EXCEPTION_STACKTRACE) String stacktrace,
			@Header(KafkaHeaders.EXCEPTION_MESSAGE) String errorMessage) {
		System.out.println(msg);
		System.out.println(ByteBuffer.wrap(offset).getLong());
		System.out.println(descException);
		System.out.println(stacktrace);
		System.out.println(errorMessage);
	}
@garyrussell garyrussell added this to the 2.8.0-RC1 milestone Sep 23, 2021
@garyrussell garyrussell self-assigned this Sep 23, 2021
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Sep 23, 2021
Resolves spring-projects#1951

Converts `byte[]` (particularly headers) to `long`, `int`, `short` or `byte` (or wrappers).
artembilan pushed a commit that referenced this issue Sep 23, 2021
Resolves #1951

Converts `byte[]` (particularly headers) to `long`, `int`, `short` or `byte` (or wrappers).
garyrussell added a commit that referenced this issue Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant