当前位置: 首页 > news >正文

建网站 温州asp与sql网站建设

建网站 温州,asp与sql网站建设,网店美工实训报告总结2000字,网页建站要多久发布/订阅是GCP提供的不错的工具。 它非常方便#xff0c;可以帮助您解决应用程序可能面临的消息传递难题。 实际上#xff0c;如果您使用GCP#xff0c;则可以使用托管消息解决方案。 如预期的那样#xff0c;使用实际的发布/订阅解决方案需要一定的配额#xff0c;因此… 发布/订阅是GCP提供的不错的工具。 它非常方便可以帮助您解决应用程序可能面临的消息传递难题。 实际上如果您使用GCP则可以使用托管消息解决方案。 如预期的那样使用实际的发布/订阅解决方案需要一定的配额因此对于 开发中必须使用不会花钱的东西。 在这些情况下您可以使用Pub / Sub 仿真器 。 要开始使用模拟器您需要先安装它 gcloud components install pubsub-emulator 确实很方便但是具有docker映像因为它更便于携带。 不幸的是没有来自Google Cloud的官方图片但是您可以使用Docker Hub上可用的解决方案之一。 现在运行它 gcloud beta emulators pubsub start --project test -project 之后您的应用程序可以连接到发布/订阅模拟器。 默认端口为8085 我将以Java单元测试为例。 package org.gkatzioura.pubsub; import java.io.IOException; import java.nio.charset.Charset; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.google.api.gax.core.CredentialsProvider; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.rpc.FixedTransportChannelProvider; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.cloud.pubsub.v1.Publisher; import com.google.cloud.pubsub.v1.SubscriptionAdminClient; import com.google.cloud.pubsub.v1.SubscriptionAdminSettings; import com.google.cloud.pubsub.v1.TopicAdminClient; import com.google.cloud.pubsub.v1.TopicAdminSettings; import com.google.cloud.pubsub.v1.stub.GrpcSubscriberStub; import com.google.cloud.pubsub.v1.stub.SubscriberStub; import com.google.cloud.pubsub.v1.stub.SubscriberStubSettings; import com.google.protobuf.ByteString; import com.google.pubsub.v1.ProjectSubscriptionName; import com.google.pubsub.v1.ProjectTopicName; import com.google.pubsub.v1.PubsubMessage; import com.google.pubsub.v1.PullRequest; import com.google.pubsub.v1.PullResponse; import com.google.pubsub.v1.PushConfig; import com.google.pubsub.v1.Subscription; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; public class LocalPubSubTest { private static final String PROJECT test-project ; private static final String SUBSCRIPTION_NAME SUBSCRIBER ; private static final String TOPIC_NAME test-topic-id ; private static final String hostPort 127.0.0.1:8085 ; private ManagedChannel channel; private TransportChannelProvider channelProvider; private TopicAdminClient topicAdmin; private Publisher publisher; private SubscriberStub subscriberStub; private SubscriptionAdminClient subscriptionAdminClient; private ProjectTopicName topicName ProjectTopicName.of(PROJECT, TOPIC_NAME); private ProjectSubscriptionName subscriptionName ProjectSubscriptionName.of(PROJECT, SUBSCRIPTION_NAME); private Subscription subscription; Before public void setUp() throws Exception { channel ManagedChannelBuilder.forTarget(hostPort).usePlaintext().build(); channelProvider FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel)); CredentialsProvider credentialsProvider NoCredentialsProvider.create(); topicAdmin createTopicAdmin(credentialsProvider); topicAdmin.createTopic(topicName); publisher createPublisher(credentialsProvider); subscriberStub createSubscriberStub(credentialsProvider); subscriptionAdminClient createSubscriptionAdmin(credentialsProvider); subscription subscriptionAdminClient.createSubscription(subscriptionName, topicName, PushConfig.getDefaultInstance(), 0); } After public void tearDown() throws Exception { topicAdmin.deleteTopic(topicName); subscriptionAdminClient.deleteSubscription(subscription.getName()); channel.shutdownNow(); } Test public void testLocalPubSub() throws Exception { final String messageText text ; PubsubMessage pubsubMessage PubsubMessage.newBuilder() .setData(ByteString.copyFrom(messageText, Charset.defaultCharset())) .build(); publisher.publish(pubsubMessage).get(); PullRequest pullRequest PullRequest.newBuilder() .setMaxMessages(1) .setReturnImmediately( true ) // if messages are not available immediately return .setSubscription(subscription.getName()) .build(); PullResponse pullResponse subscriberStub.pullCallable().call(pullRequest); String receiveMessageText pullResponse.getReceivedMessages(0).getMessage().getData().toStringUtf8(); Assert.assertEquals(messageText, receiveMessageText); } private TopicAdminClient createTopicAdmin(CredentialsProvider credentialsProvider) throws IOException { return TopicAdminClient.create( TopicAdminSettings.newBuilder() .setTransportChannelProvider(channelProvider) .setCredentialsProvider(credentialsProvider) .build() ); } private SubscriptionAdminClient createSubscriptionAdmin(CredentialsProvider credentialsProvider) throws IOException { SubscriptionAdminSettings subscriptionAdminSettings SubscriptionAdminSettings.newBuilder() .setCredentialsProvider(credentialsProvider) .setTransportChannelProvider(channelProvider) .build(); return SubscriptionAdminClient.create(subscriptionAdminSettings); } private Publisher createPublisher(CredentialsProvider credentialsProvider) throws IOException { return Publisher.newBuilder(topicName) .setChannelProvider(channelProvider) .setCredentialsProvider(credentialsProvider) .build(); } private SubscriberStub createSubscriberStub(CredentialsProvider credentialsProvider) throws IOException { SubscriberStubSettings subscriberStubSettings SubscriberStubSettings.newBuilder() .setTransportChannelProvider(channelProvider) .setCredentialsProvider(credentialsProvider) .build(); return GrpcSubscriberStub.create(subscriberStubSettings); } } 而已。 现在您可以进行一些具有成本效益的单元测试 翻译自: https://www.javacodegeeks.com/2019/09/pub-sub-local-emulator.html
http://www.zqtcl.cn/news/570981/

相关文章:

  • 哈尔滨网站关键词优化排名合江做网站
  • 手机网站自动适配旅游网络营销方案
  • 敦化网站开发黔东南购物网站开发设计
  • 建设一个网站 需要提供什么如何免费推广自己的网站
  • 佛山企业网站制作公司中国互联网企业100强榜单
  • 买了域名就可以做网站怎么创造游戏软件
  • 广东广州电脑个人建站徐州网站排名公司
  • 网站优化 流量做网站对企业有什么好处
  • 建设机械网站制作人工智能工程师月薪多少
  • wordpress 百度站长沈阳app开发公司哪家好
  • 做网站平台公司网站建设硬件环境
  • 可视化编辑建站平台新密市城乡建设局网站
  • 电子商务的网站的建设内容wordpress主题 微软
  • 什么软件可以做动画视频网站网站的按钮怎么做 视频
  • 饰品做商城网站模式17网站一起做网店新塘
  • 微信做的地方门户网站做设计的平台
  • 旅游网站建设国内外现状安卓开发软件安装教程
  • 网站建设必备网站自助建设
  • 杭州免费自助建站模板辽宁建设工程信息网为什么打不开
  • sdcms网站源码百度怎么免费做网站
  • 图书馆网站参考咨询建设wordpress安装500
  • 详细描述建设网站wordpress 子页面
  • 做公司网站推广如何快速推广
  • 给期货交易类做网站违法吗青海企业网站制作
  • 成都网站模板购买一站式营销型网站建设服务
  • wordpress建站优势做网站认证对网站有什么好处
  • synology做网站专业企业建站价格
  • php开发大型网站开发免费个人微网站
  • 专门做奢侈品的网站怎么建设课题网站
  • 博客推广那个网站列好深圳社保个人网页登录