同步调用的优势:时效性强,等到结果后才返回–需要查询结果的通常用同步调用
同步调用的问题:
流量削峰填谷–大量请求过来处理时快时慢,但是加了消息代理之后,消息存在消息代理中,根据消费者的消费速度消费消息
异步的使用场景
对性能要求高
对对方执行结果不关心,不影响当前业务
AMQP,即Advanced Message Queuing Protocol,一个提供统一消息服务的应用层标准高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计。基于此协议的客户端与消息中间件可传递消息,并不受客户端/中间件不同产品,不同的开发语言等条件的限制。Erlang中的实现有RabbitMQ等。
队列:默认消息进入是有序的,先进先出,先进入的先被消费
RabbitMQ有虚拟主机的概念,交换机和队列都有自己对应的虚拟主机
convertAndSend 传入队列名和消息
Work queues,任务模型。就是让多个消费者绑定到一个队列,共同消费队列中的消息
消息只能被消费一次
没有交换机的时候,用户发消息进入队列,消息被消费就没有了
有交换机的时候,用户发消息到交换机,交换机把消息分发到队列
交换机的作用:
不同的服务要接收不同的消息,所以用不同的交换机---------比如支付服务之后,短信微服务要接收成功和失败的消息,而扣钱的服务只接收成功的消息
Fanout Exchange会将接收到的消息广播到每一个跟其绑定的queue,所以也叫广播模式
比direct更加灵活
描述Direct交换机与Topic交换机的差异:
RabbitMQ为什么需要创建信道,为什么不是TCP直接通道
队列、交换机和绑定关系的声明一般在消费者
声明Direct交换机
缺点:写很多bean
解决:注意,是都要配置
SpringAMQP实现生产者确认
RabbitMQ实现数据持久化分为三个方面:
交换机持久化
队列持久化
消息的持久化–重启之后消息还在
给消息设置属性值为非持久化消息
设置为持久化消息
从RabbitMQ的3.6.0版本开始,就增加了Lazy Queue的概念,也就是惰性队列
惰性队列的特征如下:
在3.12版本之后,所有队列都是LazyQueue模式,无法更改
SpringAMQP已经实现了消息确认功能,并允许我们通过配置文件选择ACK处理方式,有三种方式
一般设置auto,只有消息被确认,返回ack,消息才会删除,否则重新投递
当消费者出现异常后,消息会不断requeue (重新入队) 到队列,再重新发送给消费者,然后再次异常,再次requeue,无限循环,导致mq的消息处理飙升,带来不必要的压力。
可以利用Spring的retry机制,在消费者出现异常时利用本地重试,而不是无限制的requeue到mq队列
处理失败的消息有三种不同的实现策略:一般使用第三种
代码—此配置类在消费者开启重试机制才生效
消费者如何保证消息一定被消费?
消费者消费几次消息不确定,要防止消息重复消费引起的问题
幂等性
对于非幂等的业务要保证业务幂等性
对于表单重复提交来说,可以在进入表单之前生成唯一标识发送到前端,标识在服务端保存一份,保存到redis,可以理解为一个token,然后在表单填完之后,在表单填完之后,提交时要携带token到服务端,判断token是否存在,如果存在则证明没问题,执行表单提交,提交之后删除token,如果表单重复提交,而token被删了则没有token,重复提交失败。
MQ没有token,但是可以使用这个机制
Java 消息后置处理器(MessagePostProcessor)是 Spring 框架中的一个重要概念,用于在发送和接收消息之前和之后对消息进行转换或修改。
Spring 中的消息后置处理器通常是在消息发送或接收的 MessageListenerContainer
中注册的,可以在消息发送或接收前后执行某些操作。例如,可以使用消息后置处理器在消息发送前将消息转换为特定格式,或在消息接收后将消息解密或验证。
以下是一个使用消息后置处理器将消息转换为 JSON 格式的示例:
public class JsonMessagePostProcessor implements MessagePostProcessor {
private ObjectMapper objectMapper;
public JsonMessagePostProcessor(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
@Override
public Message postProcessMessage(Message message) throws AmqpException {
try {
byte[] body = objectMapper.writeValueAsBytes(message.getBody());
MessageProperties messageProperties = message.getMessageProperties();
messageProperties.setContentType("application/json");
messageProperties.setContentEncoding("UTF-8");
return new Message(body, messageProperties);
} catch (JsonProcessingException e) {
throw new AmqpException("Failed to convert message to JSON", e);
}
}
}
在这里,我们实现了 MessagePostProcessor
接口,并重写了其中的 postProcessMessage()
方法。在这个方法中,我们将消息体转换为 JSON 字符串,并设置了消息属性的内容类型和编码方式。最后,返回新的消息对象。
要使用这个消息后置处理器,我们需要将它注册到 MessageListenerContainer
中。例如,可以在 Spring Boot 中的 RabbitListenerContainerFactory
中注册它:
@Bean
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory,
ObjectMapper objectMapper) {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setMessageConverter(new Jackson2JsonMessageConverter(objectMapper));
factory.setAfterReceivePostProcessors(new JsonMessagePostProcessor(objectMapper));
return factory;
}
在这里,我们使用 setAfterReceivePostProcessors()
方法将消息后置处理器注册到 SimpleRabbitListenerContainerFactory
中。在此之后,当消息接收到时,它将自动应用这个消息后置处理器,将消息转换为 JSON 格式。
安装 启动
实操
[root@xwk ~]# yum -y install gcc gcc-c++
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Package gcc-4.8.5-44.el7.x86_64 already installed and latest version
Package gcc-c++-4.8.5-44.el7.x86_64 already installed and latest version
Nothing to do
[root@xwk ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 already installed an d latest version
Package 7:lvm2-2.02.187-6.el7_9.5.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8. noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8. noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_9.6 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7 .noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Installing for dependencies:
libxml2-python x86_64 2.9.1-6.el7_9.6 updates 247 k
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Transaction Summary
=================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 863 k
Installed size: 4.3 M
Downloading packages:
(1/4): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
(2/4): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
(3/4): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm | 247 kB 00:00:01
(4/4): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:01
---------------------------------------------------------------------------------
Total 426 kB/s | 863 kB 00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-chardet-2.2.1-3.el7.noarch 1/4
Installing : python-kitchen-1.1.1-5.el7.noarch 2/4
Installing : libxml2-python-2.9.1-6.el7_9.6.x86_64 3/4
Installing : yum-utils-1.1.31-54.el7_8.noarch 4/4
Verifying : python-kitchen-1.1.1-5.el7.noarch 1/4
Verifying : yum-utils-1.1.31-54.el7_8.noarch 2/4
Verifying : libxml2-python-2.9.1-6.el7_9.6.x86_64 3/4
Verifying : python-chardet-2.2.1-3.el7.noarch 4/4
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7_9.6 python-chardet.noarch 0:2.2.1-3.el7
python-kitchen.noarch 0:1.1.1-5.el7
Complete!
[root@xwk ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@xwk ~]# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 118 kB 00:00:00
Metadata Cache Created
[root@xwk ~]# yum -y install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:24.0.7-1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-2 4.0.7-1.el7.x86_64
--> Processing Dependency: containerd.io >= 1.6.4 for package: 3:docker-ce-24.0.7 -1.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: 3:docker-ce-24.0.7-1.el 7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-24.0.7-1.el7.x8 6_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-24. 0.7-1.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-24.0.7-1.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinu x-2.119.2-1.911c772.el7_8.noarch
---> Package containerd.io.x86_64 0:1.6.25-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:24.0.7-1.el7 will be installed
--> Processing Dependency: docker-buildx-plugin for package: 1:docker-ce-cli-24.0 .7-1.el7.x86_64
--> Processing Dependency: docker-compose-plugin for package: 1:docker-ce-cli-24. 0.7-1.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:24.0.7-1.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless- extras-24.0.7-1.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-ext ras-24.0.7-1.el7.x86_64
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
--> Running transaction check
---> Package docker-buildx-plugin.x86_64 0:0.11.2-1.el7 will be installed
---> Package docker-compose-plugin.x86_64 0:2.21.0-1.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overl ayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overl ayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7 .2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-p ython-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreut ils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreut ils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34. el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreu tils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreu tils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreu tils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34 .el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-pyt hon-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-pyt hon-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
docker-ce x86_64 3:24.0.7-1.el7 docker-ce-stable 24 M
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 base 76 k
checkpolicy x86_64 2.5-8.el7 base 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
containerd.io x86_64 1.6.25-3.1.el7 docker-ce-stable 34 M
docker-buildx-plugin x86_64 0.11.2-1.el7 docker-ce-stable 13 M
docker-ce-cli x86_64 1:24.0.7-1.el7 docker-ce-stable 13 M
docker-ce-rootless-extras
x86_64 24.0.7-1.el7 docker-ce-stable 9.1 M
docker-compose-plugin x86_64 2.21.0-1.el7 docker-ce-stable 13 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
libcgroup x86_64 0.41-21.el7 base 66 k
libseccomp x86_64 2.3.1-4.el7 base 56 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Transaction Summary
=================================================================================
Install 1 Package (+17 Dependent packages)
Total download size: 109 M
Installed size: 384 M
Downloading packages:
(1/18): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(2/18): container-selinux-2.119.2-1.911c772.el7_8.noarch. | 40 kB 00:00:00
(3/18): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0 .11.2-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm is not installed
(4/18): docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm | 13 MB 00:00:23
(5/18): containerd.io-1.6.25-3.1.el7.x86_64.rpm | 34 MB 00:00:58
(6/18): docker-ce-24.0.7-1.el7.x86_64.rpm | 24 MB 00:00:44
(7/18): docker-ce-cli-24.0.7-1.el7.x86_64.rpm | 13 MB 00:00:22
(8/18): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(9/18): libseccomp-2.3.1-4.el7.x86_64.rpm | 56 kB 00:00:00
(10/18): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(11/18): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(12/18): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:01
(13/18): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(14/18): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:01
(15/18): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:01
(16/18): docker-ce-rootless-extras-24.0.7-1.el7.x86_64.rp | 9.1 MB 00:00:17
(17/18): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:05
(18/18): docker-compose-plugin-2.21.0-1.el7.x86_64.rpm | 13 MB 00:00:16
---------------------------------------------------------------------------------
Total 1.1 MB/s | 109 MB 01:37
Retrieving key from https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) "
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libseccomp-2.3.1-4.el7.x86_64 1/18
Installing : libcgroup-0.41-21.el7.x86_64 2/18
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 3/18
Installing : docker-buildx-plugin-0.11.2-1.el7.x86_64 4/18
Installing : setools-libs-3.3.8-4.el7.x86_64 5/18
Installing : audit-libs-python-2.8.5-4.el7.x86_64 6/18
Installing : fuse3-libs-3.6.1-4.el7.x86_64 7/18
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 8/18
Installing : python-IPy-0.75-6.el7.noarch 9/18
Installing : libsemanage-python-2.5-14.el7.x86_64 10/18
Installing : docker-compose-plugin-2.21.0-1.el7.x86_64 11/18
Installing : 1:docker-ce-cli-24.0.7-1.el7.x86_64 12/18
Installing : checkpolicy-2.5-8.el7.x86_64 13/18
Installing : policycoreutils-python-2.5-34.el7.x86_64 14/18
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 15/18
Installing : containerd.io-1.6.25-3.1.el7.x86_64 16/18
Installing : docker-ce-rootless-extras-24.0.7-1.el7.x86_64 17/18
Installing : 3:docker-ce-24.0.7-1.el7.x86_64 18/18
Verifying : containerd.io-1.6.25-3.1.el7.x86_64 1/18
Verifying : 3:docker-ce-24.0.7-1.el7.x86_64 2/18
Verifying : checkpolicy-2.5-8.el7.x86_64 3/18
Verifying : docker-ce-rootless-extras-24.0.7-1.el7.x86_64 4/18
Verifying : docker-compose-plugin-2.21.0-1.el7.x86_64 5/18
Verifying : libsemanage-python-2.5-14.el7.x86_64 6/18
Verifying : 1:docker-ce-cli-24.0.7-1.el7.x86_64 7/18
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 8/18
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 9/18
Verifying : python-IPy-0.75-6.el7.noarch 10/18
Verifying : libseccomp-2.3.1-4.el7.x86_64 11/18
Verifying : policycoreutils-python-2.5-34.el7.x86_64 12/18
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 13/18
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 14/18
Verifying : setools-libs-3.3.8-4.el7.x86_64 15/18
Verifying : docker-buildx-plugin-0.11.2-1.el7.x86_64 16/18
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 17/18
Verifying : libcgroup-0.41-21.el7.x86_64 18/18
Installed:
docker-ce.x86_64 3:24.0.7-1.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7
checkpolicy.x86_64 0:2.5-8.el7
container-selinux.noarch 2:2.119.2-1.911c772.el7_8
containerd.io.x86_64 0:1.6.25-3.1.el7
docker-buildx-plugin.x86_64 0:0.11.2-1.el7
docker-ce-cli.x86_64 1:24.0.7-1.el7
docker-ce-rootless-extras.x86_64 0:24.0.7-1.el7
docker-compose-plugin.x86_64 0:2.21.0-1.el7
fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7
libcgroup.x86_64 0:0.41-21.el7
libseccomp.x86_64 0:2.3.1-4.el7
libsemanage-python.x86_64 0:2.5-14.el7
policycoreutils-python.x86_64 0:2.5-34.el7
python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
[root@xwk ~]# systemctl start docker
[root@xwk ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:c79d06dfdfd3d3eb04cafd0dc2bacab0992ebc243e083cabe208bac4dd7759e0
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
[root@xwk ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@xwk ~]# docker search rabbitmq
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
rabbitmq RabbitMQ is an open source multi-protocol me… 4938 [OK]
bitnami/rabbitmq Bitnami Docker Image for RabbitMQ 110 [OK]
circleci/rabbitmq-delayed https://github.com/circleci/rabbitmq-delayed… 1
circleci/rabbitmq This image is for internal use 0
bitnami/rabbitmq-cluster-operator 1
rapidfort/rabbitmq RapidFort optimized, hardened image for Rabb… 9
bitnamicharts/rabbitmq 2
elestio/rabbitmq Rabbitmq, verified and packaged by Elestio 0
bitnamicharts/rabbitmq-cluster-operator 0
masstransit/rabbitmq Contains the RabbitMQ management Docker imag… 12
itisfoundation/rabbitmq 0
nasqueron/rabbitmqadmin RabbitMQ management plugin CLI tool Lightwei… 1 [OK]
clearlinux/rabbitmq RabbitMQ multi-protocol messaging broker wit… 0
itzg/rabbitmq-stomp Extension of the official rabbitmq image tha… 0 [OK]
corpusops/rabbitmq https://github.com/corpusops/docker-images/ 0
brightercommand/rabbitmq RabbitMQ management with delay plugin enabled 0
drud/rabbitmq rabbitmq 0 [OK]
nasqueron/rabbitmq RabbitMQ wth management, MQTT and STOMP plug… 0 [OK]
exozet/rabbitmq-delay-management deprecated 1
uselagoon/rabbitmq 0
betterweb/rabbitmq 0
newrelic/k8s-nri-rabbitmq New Relic Infrastructure RabbitMQ Integratio… 0
uselagoon/rabbitmq-cluster 0
betterweb/rabbitmq-swarm-cluster https://gitlab.com/BetterCorp/public/rabbitm… 0
faucet/event-adapter-rabbitmq Faucet rabbitmq event adaptor docker image … 0
[root@xwk ~]# docker search rabbitmq-management
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
edtechfoundry/rabbitmq-management-shovel RabbitMQ image using 3.6.6 with management a… 0
macintoshplus/rabbitmq-management Based on rabbitmq:management whit python and… 10 [OK]
theomathieu/rabbitmq-management-delayed 0
penpublicreps/rabbitmq-management 0
erikopa/rabbitmq-management-x-delayed-message RabbitMQ Management Docker with delayed mess… 0
tiagomtotti/rabbitmq-management 3
timic/rabbitmq-management-delay-x RabbitMQ with enabled management and delayed… 0 [OK]
statewide/rabbitmq-management-mqtt RabbitMQ + Management UI + MQTT 0
almasry/rabbitmq-management rabbitmq-management docker file 0
vyotov/rabbitmq-management 0
janatrix/rabbitmq-management-delay-x 0
datatrion/rabbitmq-management-stomp-alpine 0
cproinger/rabbitmq-management-monitoring 0
diamanti/rabbitmq-management 0
invitado/rabbitmq-management RabbitMQ with delayed messages plugin 0 [OK]
lixiaojunzy/rabbitmq-management-delayed rabbitmq-management-delayed 0
jatescher/rabbitmq-management RabbitMQ management pre-release images 0
pk3390/rabbitmq-management 0
jorgemarizan/rabbitmq-management-stomp-alpine Alpine based Docker image for setting up Rab… 0 [OK]
xvjialing/rabbitmq-management-alpine-mqtt rabbitmq-management-alpine开启mqtt 0
seamusv/rabbitmq-management-mqtt RabbitMQ Management with MQTT 0
valourus/rabbitmq-management 0
yoransys/rabbitmq-management-operator 0
kukmedis/rabbitmq-management-scheduler 0
antonchernik/rabbitmq-management 0
[root@xwk ~]# docker pull macintoshplus/rabbitmq-management
Using default tag: latest
latest: Pulling from macintoshplus/rabbitmq-management
51f5c6a04d83: Pull complete
7caf121ef6ce: Pull complete
15251c337a9c: Pull complete
62030bf89da6: Pull complete
04daca667d4c: Pull complete
eaa1a75dba32: Pull complete
7fde5fa62fab: Pull complete
53d15e8d48cb: Pull complete
6795f6786bbf: Pull complete
f28d9f880bec: Pull complete
3e83ffbe5f7f: Pull complete
4b72a6615452: Pull complete
97e4568e922f: Pull complete
47592ee02f76: Pull complete
6a04b53fbf65: Pull complete
442e1433375a: Pull complete
112adbb2a6fc: Pull complete
Digest: sha256:cd8fae9e67bba62f42d42fb311b5c9ce130572fafcbcaaa9575a3d8859c8641b
Status: Downloaded newer image for macintoshplus/rabbitmq-management:latest
docker.io/macintoshplus/rabbitmq-management:latest
[root@xwk ~]# docker run -d --name rabbitmq -e rabbitmq_default_user=guest -e rabbitmq_user_pass=guest -p 15672:15672 -p 5672:5672 c20
afb5e14173fe9347bc8f37c782bfcd227e7140471df02d2ed21c068d208a7beb
[root@xwk ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afb5e14173fe c20 "/docker-entrypoint.…" 10 seconds ago Up 9 seconds 4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp rabbitmq
[root@xwk ~]#