CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
this.rabbitTemplate.convertAndSend(this.routingKey, message, correlationData);
RabbitAdmin类
public void initialize() {
if (this.applicationContext == null) {
if (this.logger.isDebugEnabled()) {
this.logger
.debug("no ApplicationContext has been set, cannot auto-declare Exchanges, Queues, and Bindings");
}
return;
}
logger.debug("Initializing declarations");
final Collection exchanges = filterDeclarables(applicationContext.getBeansOfType(Exchange.class).values());
final Collection queues = filterDeclarables(applicationContext.getBeansOfType(Queue.class).values());
final Collection bindings = filterDeclarables(applicationContext.getBeansOfType(Binding.class).values());
for (Exchange exchange : exchanges) {
if (!exchange.isDurable()) {
logger.warn("Auto-declaring a non-durable Exchange ("
+ exchange.getName()
+ "). It will be deleted by the broker if it shuts down, and can be redeclared by closing and reopening the connection.");
}
if (exchange.isAutoDelete()) {
logger.warn("Auto-declaring an auto-delete Exchange ("
+ exchange.getName()
+ "). It will be deleted by the broker if not in use (if all bindings are deleted), but will only be redeclared if the connection is closed and reopened.");
}
}
for (Queue queue : queues) {
if (!queue.isDurable()) {
logger.warn("Auto-declaring a non-durable Queue ("
+ queue.getName()
+ "). It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.");
}
if (queue.isAutoDelete()) {
logger.warn("Auto-declaring an auto-delete Queue ("
+ queue.getName()
+ "). It will be deleted by the broker if not in use, and all messages will be lost. Redeclared when the connection is closed and reopened.");
}
if (queue.isExclusive()) {
logger.warn("Auto-declaring an exclusive Queue ("
+ queue.getName()
+ "). It cannot be accessed by consumers on another connection, and will be redeclared if the connection is reopened.");
}
}
rabbitTemplate.execute(new ChannelCallback
send 方法
public void send(final String exchange, final String routingKey,
final Message message, final CorrelationData correlationData)
throws AmqpException {
execute(new ChannelCallback
protected T doExecute(RetryCallback retryCallback, RecoveryCallback recoveryCallback, RetryState state)
throws Exception, ExhaustedRetryException {
RetryPolicy retryPolicy = this.retryPolicy;
BackOffPolicy backOffPolicy = this.backOffPolicy;
// Allow the retry policy to initialise itself...
RetryContext context = open(retryPolicy, state);
if (logger.isTraceEnabled()) {
logger.trace("RetryContext retrieved: " + context);
}
// Make sure the context is available globally for clients who need
// it...
RetrySynchronizationManager.register(context);
Throwable lastException = null;
try {
// Give clients a chance to enhance the context...
boolean running = doOpenInterceptors(retryCallback, context);
if (!running) {
throw new TerminatedRetryException("Retry terminated abnormally by interceptor before first attempt");
}
// Get or Start the backoff context...
BackOffContext backOffContext = null;
AttributeAccessor attributeAccessor = null;
if (context instanceof AttributeAccessor) {
attributeAccessor = (AttributeAccessor) context;
Object resource = attributeAccessor.getAttribute("backOffContext");
if (resource instanceof BackOffContext) {
backOffContext = (BackOffContext) resource;
}
}
if (backOffContext == null) {
backOffContext = backOffPolicy.start(context);
if (attributeAccessor != null && backOffContext != null) {
attributeAccessor.setAttribute("backOffContext", backOffContext);
}
}
/*
* We allow the whole loop to be skipped if the policy or context
* already forbid the first try. This is used in the case of
* external retry to allow a recovery in handleRetryExhausted
* without the callback processing (which would throw an exception).
*/
while (canRetry(retryPolicy, context) && !context.isExhaustedOnly()) {
try {
logger.debug("Retry: count=" + context.getRetryCount());
// Reset the last exception, so if we are successful
// the close interceptors will not think we failed...
lastException = null;
return retryCallback.doWithRetry(context);
}
catch (Throwable e) {
lastException = e;
doOnErrorInterceptors(retryCallback, context, e);
try {
registerThrowable(retryPolicy, state, context, e);
} catch (Exception ex) {
throw new TerminatedRetryException("Could not register throwable", ex);
}
if (canRetry(retryPolicy, context) && !context.isExhaustedOnly()) {
try {
backOffPolicy.backOff(backOffContext);
}
catch (BackOffInterruptedException ex) {
lastException = e;
// back off was prevented by another thread - fail
// the retry
logger.debug("Abort retry because interrupted: count=" + context.getRetryCount());
throw ex;
}
}
logger.debug("Checking for rethrow: count=" + context.getRetryCount());
if (shouldRethrow(retryPolicy, context, state)) {
logger.debug("Rethrow in retry for policy: count=" + context.getRetryCount());
throw wrapIfNecessary(e);
}
}
/*
* A stateful attempt that can retry should have rethrown the
* exception by now - i.e. we shouldn't get this far for a
* stateful attempt if it can retry.
*/
}
logger.debug("Retry failed last attempt: count=" + context.getRetryCount());
if (context.isExhaustedOnly()) {
throw new ExhaustedRetryException("Retry exhausted after last attempt with no recovery path.", context
.getLastThrowable());
}
return handleRetryExhausted(recoveryCallback, context, state);
}
finally {
close(retryPolicy, context, state, lastException == null);
doCloseInterceptors(retryCallback, context, lastException);
RetrySynchronizationManager.clear();
}
public final Connection createConnection() throws AmqpException {
synchronized (this.connectionMonitor) {
if (this.cacheMode == CacheMode.CHANNEL) {
if (this.connection == null) {
this.connection = new ChannelCachingConnectionProxy(super.createBareConnection());
// invoke the listener *after* this.connection is assigned
//创建连接的时候 connection
getConnectionListener().onCreate(connection);
}
return this.connection;
}
this.connectionFactory.addConnectionListener(new ConnectionListener() {
// Prevent stack overflow...
private final AtomicBoolean initializing = new AtomicBoolean(false);
@Override
public void onCreate(Connection connection) {
if (!initializing.compareAndSet(false, true)) {
// If we are already initializing, we don't need to do it again...
return;
}
try {
/*
* ...but it is possible for this to happen twice in the same ConnectionFactory (if more than
* one concurrent Connection is allowed). It's idempotent, so no big deal (a bit of network
* chatter). In fact it might even be a good thing: exclusive queues only make sense if they are
* declared for every connection. If anyone has a problem with it: use auto-startup="false".
*/
initialize();
}
finally {
initializing.compareAndSet(true, false);
}
}
Open Source Obfuscators
ProGuard
http://java-source.net/open-source/obfuscators/proguardProGuard is a free Java class file shrinker and obfuscator. It can detect and remove unused classes, fields, m
Maven简介
是什么?
Is a software project management and comprehension tool.项目管理工具
是基于POM概念(工程对象模型)
[设计重复、编码重复、文档重复、构建重复,maven最大化消除了构建的重复]
[与XP:简单、交流与反馈;测试驱动开发、十分钟构建、持续集成、富有信息的工作区]
功能:
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。
异常一:
make[2]: cc: Command not found
异常原因:没有安装g
nimbus结点配置(storm.yaml)信息:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional inf