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

Pub sub does not seem to work with Java 7 because of gRPC/netty stuff #3048

Closed
j256 opened this issue Mar 15, 2018 · 5 comments
Closed

Pub sub does not seem to work with Java 7 because of gRPC/netty stuff #3048

j256 opened this issue Mar 15, 2018 · 5 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@j256
Copy link

j256 commented Mar 15, 2018

Although the docs state that Java 8 is required, this invalidates its use in my corporate code base which is back on Java 7. I do see that the class files are Java 7 compliant however. Is it possible to run under Java 7? Are there versions of the API that work under 7?

@garrettjonesgoogle
Copy link
Member

Java 8 is only really required when running under App Engine; otherwise Java 7 is the minimum version ( see https://github.com/GoogleCloudPlatform/google-cloud-java#java-versions ).

@garrettjonesgoogle garrettjonesgoogle added the type: question Request for information or clarification. Not an issue. label Mar 15, 2018
@j256
Copy link
Author

j256 commented Mar 15, 2018

Sigh. Sorry about that. Not sure where I got Java 8 from. Thanks for the quick response.

@j256 j256 closed this as completed Mar 15, 2018
@j256 j256 reopened this Mar 15, 2018
@j256
Copy link
Author

j256 commented Mar 15, 2018

Although Pub/Sub runs under Java 7, I can't get the following test program to work with version 0.36, 37, or 38. I'm getting the java.lang.ClassNotFoundException: org/eclipse/jetty/alpn/ALPN class not found error but not in the main but deep in netty-land which implies that it is in a different classloader. It runs under Java 8 however so I suspect that maybe a dependency has a requirement? Or maybe this is a security manager issue....

Test program:

public class TestMain {
	public static void main(String[] args) throws Exception {
		Class.forName("org.eclipse.jetty.alpn.ALPN", true, TestMain.class.getClassLoader());
		String projectId = "my-project";
		String topicId = "test-topic";
		String subscriberId = "test-main";
		ProjectSubscriptionName subsciptionName = ProjectSubscriptionName.of(projectId, subscriberId);
		// SubscriptionName subsciptionName = SubscriptionName.of(projectId, subscriberId);
		Builder builder = Subscriber.newBuilder(subsciptionName, new OurReceiver());
		GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream("/tmp/creds.json"));
		builder.setCredentialsProvider(FixedCredentialsProvider.create(credentials));
		Subscriber subscriber = builder.build();
		subscriber.startAsync().awaitRunning();
		subscriber.awaitTerminated(10000000, TimeUnit.MILLISECONDS);
	}
	private static class OurReceiver implements MessageReceiver {
		@Override
		public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
			System.out.println("received message: " + message.getMessageId());
			consumer.ack();
		}
	}
}

My pom is just:

	<dependencies>
		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>google-cloud-pubsub</artifactId>
			<version>0.38.0-beta</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
		</plugins>
	</build>

@j256
Copy link
Author

j256 commented Mar 15, 2018

This looks like a problem with the netty gprc 1.9.0.

@j256 j256 changed the title Use with Java 7? Pub sub does not seem to work with Java 7 because of gRPC/netty stuff Mar 15, 2018
@j256
Copy link
Author

j256 commented Mar 19, 2018

I'm going to close this because it is an overlap with #3044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants