Java Graylog Google发布/订阅输出插件问题

Java Graylog Google发布/订阅输出插件问题,java,google-cloud-pubsub,graylog,graylog3,Java,Google Cloud Pubsub,Graylog,Graylog3,我们正在构建一个Graylog输出插件,将数据发送到Google PubSub。这是我们编写的代码,灵感来源于google pubsub提供的样板代码(和) 我们甚至看过github回购协议,但似乎无法解决问题。我们在通信中没有使用grpc,但我们认为google pubsub java模块正在内部使用grpc 任何帮助都将不胜感激。提前谢谢。我也有同样的问题, 我的应用程序是用scala(用sbt)开发的,但maven也是这样。 要解决此问题,我使用以下方法更改依赖项: libraryDepe

我们正在构建一个Graylog输出插件,将数据发送到Google PubSub。这是我们编写的代码,灵感来源于google pubsub提供的样板代码(和)

我们甚至看过github回购协议,但似乎无法解决问题。我们在通信中没有使用grpc,但我们认为google pubsub java模块正在内部使用grpc

任何帮助都将不胜感激。提前谢谢。

我也有同样的问题, 我的应用程序是用scala(用sbt)开发的,但maven也是这样。 要解决此问题,我使用以下方法更改依赖项:

libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.75.0"
libraryDependencies += "com.google.api-client" % "google-api-client" % "1.30.5"
libraryDependencies += "com.google.cloud" % "google-cloud-core-grpc" % "1.91.3"
对于代码,只需保留创建google凭据对象的默认方式:

def publishMessages(projectId : String, topic : String, event : String): Unit = { 
    val topicName = ProjectTopicName.of(projectId, topic)
    var publisher : Publisher = null
    val messageIdFutures = new util.ArrayList[ApiFuture[String]]
    try {
      val credentials = GoogleCredentials.fromStream(new FileInputStream(creds)).createScoped(
        java.util.Arrays.asList("https://www.googleapis.com/auth/cloud-platform")
      )
      publisher = Publisher.newBuilder(topicName)
        .setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build

      val payload = ByteString.copyFromUtf8(event)
      val pubsubMessage = PubsubMessage.newBuilder.setData(payload).build
      val messageIdFuture = publisher.publish(pubsubMessage)
      messageIdFutures.add(messageIdFuture)
}

似乎它与opencensus中的这一变化有关,您可以使用之前的版本(0.24.0之前)进行测试吗?
libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.75.0"
libraryDependencies += "com.google.api-client" % "google-api-client" % "1.30.5"
libraryDependencies += "com.google.cloud" % "google-cloud-core-grpc" % "1.91.3"
def publishMessages(projectId : String, topic : String, event : String): Unit = { 
    val topicName = ProjectTopicName.of(projectId, topic)
    var publisher : Publisher = null
    val messageIdFutures = new util.ArrayList[ApiFuture[String]]
    try {
      val credentials = GoogleCredentials.fromStream(new FileInputStream(creds)).createScoped(
        java.util.Arrays.asList("https://www.googleapis.com/auth/cloud-platform")
      )
      publisher = Publisher.newBuilder(topicName)
        .setCredentialsProvider(FixedCredentialsProvider.create(credentials)).build

      val payload = ByteString.copyFromUtf8(event)
      val pubsubMessage = PubsubMessage.newBuilder.setData(payload).build
      val messageIdFuture = publisher.publish(pubsubMessage)
      messageIdFutures.add(messageIdFuture)
}